digitalmars.D - uniform tuple syntax
- Vlad Levenfeld (2/2) Mar 24 2015 Anything going on with this? Been looking forward to seeing it
- Martin Nowak (7/8) Mar 24 2015 I think we should settle on a syntax and split DIP32 in a tuple part and
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (4/8) Mar 24 2015 Using "$" for something completely different is confusing, but it
- Vlad Levenfeld (15/27) Mar 24 2015 Anything wrong with using {}? It looks good to me, does it lead
- deadalnix (2/15) Mar 24 2015 This syntax is over over loaded.
- Adam D. Ruppe (10/12) Mar 24 2015 In this context, it would look like a delegate/function literal
- Brian Schott (5/7) Mar 24 2015 Before:
- "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= (13/17) Mar 25 2015 No, in Unix "$" is used in /bin/sh for the prompt and to denote a
- ixid (3/15) Mar 24 2015 What was the conclusion about parens tuples? They would be much
- Rikki Cattermole (9/17) Mar 24 2015 There is one thing blatantly missing atleast to me.
- Andrei Alexandrescu (3/21) Mar 24 2015 myfunc(tuple(1, "hi!").expand);
- Rikki Cattermole (2/26) Mar 24 2015 In that case, +1 on my vote for being complete.
- Vlad Levenfeld (38/62) Mar 24 2015 Yeah, treating the builtin tuple the same way as, say, a
- bearophile (4/6) Mar 25 2015 It will happen.
Anything going on with this? Been looking forward to seeing it for awhile.
Mar 24 2015
On 03/24/2015 03:11 PM, Vlad Levenfeld wrote:Anything going on with this? Been looking forward to seeing it for awhile.I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32
Mar 24 2015
On Tuesday, 24 March 2015 at 18:12:03 UTC, Martin Nowak wrote:wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32Using "$" for something completely different is confusing, but it can be automated.
Mar 24 2015
On Tuesday, 24 March 2015 at 18:12:03 UTC, Martin Nowak wrote:I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32Anything wrong with using {}? It looks good to me, does it lead to any parsing ambiguities? I just want to get all the .tuple and .expand and tuple parameter function overload litter out of my code. My use cases are multiple returns and parameters-first UFCS. It'd be great if {arg1, arg2}.func1.func2; matched the signature auto func1 (T,U)(T arg1, U arg2); On Tuesday, 24 March 2015 at 18:38:51 UTC, Ola Fosheim Grøstad wrote:Using "$" for something completely different is confusing, but it looks ok. Maybe rename existing use of "$" for length toYou'd also have to rename opDollar to opHash or, maybe less confusingly, opPound. Also, $ is already a common idiom (at least in Unix) for "the end". It would be better to just name the
Mar 24 2015
On Tuesday, 24 March 2015 at 23:07:29 UTC, Vlad Levenfeld wrote:On Tuesday, 24 March 2015 at 18:12:03 UTC, Martin Nowak wrote:This syntax is over over loaded.I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32Anything wrong with using {}? It looks good to me, does it lead to any parsing ambiguities?
Mar 24 2015
On Tuesday, 24 March 2015 at 23:07:29 UTC, Vlad Levenfeld wrote:Anything wrong with using {}? It looks good to me, does it lead to any parsing ambiguities?In this context, it would look like a delegate/function literal or perhaps the start of a scope in other contexts. auto a = { arg1, arg2 }; // a is a function pointer, not a tuple // ( that won't compile cuz of a missing semicolon inside but still ) { int } would look like a block scope. Again, it wouldn't compile because the int is missing an identifier, but still, it would pose a parsing problem.
Mar 24 2015
On Tuesday, 24 March 2015 at 23:07:29 UTC, Vlad Levenfeld wrote:Anything wrong with using {}? It looks good to me, does it lead to any parsing ambiguities?Before: auto x = {}; // struct or function? After: auto x = {}; // struct, function, or tuple??
Mar 24 2015
On Tuesday, 24 March 2015 at 23:07:29 UTC, Vlad Levenfeld wrote:You'd also have to rename opDollar to opHash or, maybe less confusingly, opPound.opLength?Also, $ is already a common idiom (at least in Unix) for "the end". It would be better to just nameNo, in Unix "$" is used in /bin/sh for the prompt and to denote a "${#variable}" is used for length. What you are thinking about is that "$" is used for pattern matching of the conceptual EOL-symbol (character) in regular expressions, but that's not length. So in the Unix world "$" is either used for variables or pattern the length operator? Using "$" for length is just confusing if you know other languages.
Mar 25 2015
On Tuesday, 24 March 2015 at 18:12:03 UTC, Martin Nowak wrote:On 03/24/2015 03:11 PM, Vlad Levenfeld wrote:What was the conclusion about parens tuples? They would be much prettier.Anything going on with this? Been looking forward to seeing it for awhile.I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32
Mar 24 2015
On 25/03/2015 7:11 a.m., Martin Nowak wrote:On 03/24/2015 03:11 PM, Vlad Levenfeld wrote:There is one thing blatantly missing atleast to me. Unpacking into function arguments. void myfunc(int x, string y) { // ... } myfunc({1, "hi!"}.unpack); Lua has something along these lines for tables. And it is a real hit. Of course .unpack probably isn't needed, but hey it makes it more explicit.Anything going on with this? Been looking forward to seeing it for awhile.I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32
Mar 24 2015
On 3/24/15 8:00 PM, Rikki Cattermole wrote:On 25/03/2015 7:11 a.m., Martin Nowak wrote:myfunc(tuple(1, "hi!").expand); AndreiOn 03/24/2015 03:11 PM, Vlad Levenfeld wrote:There is one thing blatantly missing atleast to me. Unpacking into function arguments. void myfunc(int x, string y) { // ... } myfunc({1, "hi!"}.unpack);Anything going on with this? Been looking forward to seeing it for awhile.I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32
Mar 24 2015
On 25/03/2015 5:13 p.m., Andrei Alexandrescu wrote:On 3/24/15 8:00 PM, Rikki Cattermole wrote:In that case, +1 on my vote for being complete.On 25/03/2015 7:11 a.m., Martin Nowak wrote:myfunc(tuple(1, "hi!").expand); AndreiOn 03/24/2015 03:11 PM, Vlad Levenfeld wrote:There is one thing blatantly missing atleast to me. Unpacking into function arguments. void myfunc(int x, string y) { // ... } myfunc({1, "hi!"}.unpack);Anything going on with this? Been looking forward to seeing it for awhile.I think we should settle on a syntax and split DIP32 in a tuple part and a pattern matching part. The proposal wasn't yet formally accepted, partly because we wanted to wait, whether more needs come up. By now it's already 2 years old and it still looks complete IMO. http://wiki.dlang.org/DIP32
Mar 24 2015
On Wednesday, 25 March 2015 at 04:13:03 UTC, Andrei Alexandrescu wrote:On 3/24/15 8:00 PM, Rikki Cattermole wrote:Yeah, treating the builtin tuple the same way as, say, a TypeTuple, would be cool. For everything else, there's the library tuple. I've noticed that I can do TypeTuple!(arg1, arg2, arg3).func; but this only works if the args are symbols (which can be aliased), but not for expressions. What I'd really like is to say {2 + 4, `he` ~ `llo`}.myfunc; Without an explicit "tuple" or "expand". Also, putting something into a library tuple forces a copy, but I think it'd be nice if the symbols in builtin tuples could be ref. In other words, make {} mean roughly the same thing as TypeTuple (which have a misleading name as they can be used for everything, not just types, which is why I rename TypeTuple to Cons in my code). On Tuesday, 24 March 2015 at 23:57:53 UTC, Adam D. Ruppe wrote:There is one thing blatantly missing atleast to me. Unpacking into function arguments. void myfunc(int x, string y) { // ... } myfunc({1, "hi!"}.unpack);myfunc(tuple(1, "hi!").expand); AndreiIn this context, it would look like a delegate/function literal or perhaps the start of a scope in other contexts. auto a = { arg1, arg2 }; // a is a function pointer, not a tuple // ( that won't compile cuz of a missing semicolon inside but still ) { int } would look like a block scope. Again, it wouldn't compile because the int is missing an identifier, but still, it would pose a parsing problem.So, the first case should be a tuple. As a function, {} means the same thing as (){}. I don't really like this, and never use this {} notation anyway, because my syntax highlighting chokes on it. In any case, requiring an argument list before a function definition would resolve the ambiguity. In any case, the issue would come to light the moment "a" was actually used. "Tuples don't overload opCall" or something. Or it might get caught by some type-checking logic before that. Unless "a" were never used, in which case it doesn't really matter what it resolves to (unless it were being declared specifically to be stored or in TMP, in which case naming the explicit type is a better practice anyway). As for the second, it should just be a TypeTuple, if anything. If that's not possible, then its an error. As for which error, I'd say its safe to assume its a scope and give the "no identifier" error. On Tuesday, 24 March 2015 at 23:59:20 UTC, Brian Schott wrote:Before: auto x = {}; // struct or function? After: auto x = {}; // struct, function, or tuple??For the before case, it's gotta be a function, because it doesn't make sense to use a brace-enclosed initializer without any type information. The "after" case should be interpreted as a tuple, for reasons outlined above.
Mar 24 2015
Vlad Levenfeld:Anything going on with this? Been looking forward to seeing it for awhile.It will happen. Bye, bearophile
Mar 25 2015