- Notifications
You must be signed in to change notification settings - Fork 248
C99 Struct Initialisers #32
Conversation
| @dannygreg I’m so curious, why? |
| Sorry, I should possibly have been more explanatory in my description. Essentially, if I am reading Another great positive is that if structs are compositions of other struct types we can mix and match what we use to initialise it. For example, a
Which is more convenient than being forced to break everything up into individual values for a function like Hopefully that cleans things up, I feel incapable of effectively writing English today… probably need more ☕ |
| Ummm… What if, say P.S.: if I sound like arguing just for the sake of it, then ignore… 😕 |
Absolutely nothing wrong with argument, as long as it's rational and on topic. In this case it is definitely both 😄
Fair point, but as these will be public structs any change in them, which would break this, would would also break any direct access to members (such as using If a struct is declared publicly, it's fairly safe to assume it won't change. |
| 👍 |
README.md Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/NSRect/CGRect/ :trollface:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s a funny face tho 😄
@aroben what’s that “repo collab" label–thing on your name please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dannygreg how come I don’t get those in my organization repos? Maybe only external people see those labels? Not sure...
Been doing too much AppKit recently it seems.
@exalted Designated initializers (which is how C99 refers to them) would only break if the names of the fields changed – they don't depend on the specific order or layout of the fields, if that's what you meant. |
README.md Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need to show this example if we have the above (and it's right under the bullet point).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed (if we add the example as suggested below).
| 🎒 |
| 🏉 |
| 🏈 |
Document a preference for verbose struct initialisers rather than helper functions. These are easier to read and allow structs to be initialise with any sub-structs rather than having to use their members explicitly.