Variadics syntax #4735
Replies: 1 comment 3 replies
-
No problem, and yeah, this isn't yet implemented.
FWIW, I do understand this confusion, but I'm not sure how we can address it. Most of the variadics approaches I've seen suffer from this, and all I really know to do is document and teach it so people don't accidentally fall into the wrong mental model.
We have talked about requiring more parentheses to help reduce confusion here:
Yeah, we're just trying to find the right balance. We've seen in C++ a ton of reasons why having some syntactic marker for the expanded entity clarifies things, and the best syntax we saw for it came from Swift (huge props there). We thought we could minimize the syntactic weight of the whole construct by taking C++'s We could look at other balances, but I think here too it would be useful to get a bit more code written in Carbon before we spend a lot more time trying to tweak the exact syntactic balance. What we have seems reasonable solid and teachable, and so our current priority is to get more implemented and get code written using this. We should be able to then revisit some of these purely syntactic questions pretty easily based on feedback and user experience and any new ideas that folks have. |
Beta Was this translation helpful? Give feedback.
-
Hi everybody!
After watching "How Designing Carbon C++ Interop Taught me About C++ Variadics & Bound Members - Chandler Carruth" variadics
syntax does not feel intuitive to me. For context I am C++ dev.
First of all apologies for potential misunderstandings since I could not get the examples from slides working on godbolt.
There are few issues here that make syntax weird for me:
return IntSum(... each param * each param);
screams Cartesian Product to me, not square every item in pack... *each value -=min;
feels wrong because my expectation is that dereference operates on pointer appearing immediately after*
....
andeach
seems to heavy although I prefer nicer syntax compared to obscure C++ one, and I think Swift has even more verbose syntaxI have some ideas what would be nicer syntax but don't want to mention them since I know too little about language grammar, i.e. what options are available without making parsing a nightmare.
Beta Was this translation helpful? Give feedback.
All reactions