Jump to page: 1 2
Thread overview
uniform tuple syntax
Mar 24, 2015
Vlad Levenfeld
Mar 24, 2015
Martin Nowak
Mar 24, 2015
Vlad Levenfeld
Mar 24, 2015
deadalnix
Mar 24, 2015
Adam D. Ruppe
Mar 24, 2015
Brian Schott
Mar 25, 2015
ixid
Mar 25, 2015
Rikki Cattermole
Mar 25, 2015
Rikki Cattermole
Mar 25, 2015
Vlad Levenfeld
Mar 25, 2015
bearophile
March 24, 2015
Anything going on with this? Been looking forward to seeing it for awhile.
March 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
March 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/DIP32

Using "$" for something completely different is confusing, but it looks ok. Maybe rename existing use of "$" for length to "#"? It can be automated.
March 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/DIP32

Anything 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 to "#"? It can be automated.

You'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 pattern matching symbol # instead.
March 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:
>> 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
>
> Anything wrong with using {}? It looks good to me, does it lead to any parsing ambiguities?

This syntax is over over loaded.
March 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.
March 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??
March 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:
>> 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

What was the conclusion about parens tuples? They would be much prettier.
March 25, 2015
On 25/03/2015 7:11 a.m., Martin Nowak wrote:
> 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

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.
March 25, 2015
On 3/24/15 8:00 PM, Rikki Cattermole wrote:
> On 25/03/2015 7:11 a.m., Martin Nowak wrote:
>> 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
>
> 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);

Andrei

« First   ‹ Prev
1 2