August 21, 2013
On 8/21/13 9:01 AM, Daniel Murphy wrote:
> "Meta" <jared771@gmail.com> wrote in message
> news:evamvyfxasouvwzublxc@forum.dlang.org...
>> That said, I'd like to open the discussion on tuple syntax yet again.
>
> How about angle brackets?
>
> auto x = <1, 3>;
> auto <a, b> = x;

No please.

Andrei

August 21, 2013
On Wednesday, 21 August 2013 at 17:40:55 UTC, bearophile wrote:
> f. unpacking small arrays.
>
> auto a = [10, 20];
> const x = a[0];
> const y = a[1];

I don't know if you saw this, but I mentioned in my other post an interesting thing you could do if compiler tuples had an unpacking syntax. You currently can't use tupleof with array, but allowing it would also allow any hypothetical unpacking syntax to unpack an array. An example:

int[3] arr = [1, 2, 3];
//a = 1, b = 2, c = 3
auto (a, b, c) = arr.tupleof;



August 21, 2013
On Wednesday, 21 August 2013 at 16:39:14 UTC, Jacob Carlborg wrote:
> On 2013-08-21 18:01, Daniel Murphy wrote:
>
>> How about angle brackets?
>>
>> auto x = <1, 3>;
>> auto <a, b> = x;
>
> Aren't we then back to the same problems C++ have with its template syntax?
I propose <<<<a, b>>>> to prevent any token ambiguities with <<< and >>.

PS. Poor Andrei.
August 21, 2013
On 8/20/2013 1:10 PM, Jonathan M Davis wrote:
> On Tuesday, August 20, 2013 13:06:27 H. S. Teoh wrote:
>> On Tue, Aug 20, 2013 at 11:53:50AM -0700, Andrei Alexandrescu wrote:
>>> Somebody shoot me.
>>
>> [...]
>>
>> BANG!
>
> Don't kill him. He hasn't finished the allocators yet! ;)

Don't worry, we'll keep sliding food under his door!

August 21, 2013
On 2013-08-21 16:59:17 +0000, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> said:

> On 8/20/13 8:25 PM, Michel Fortin wrote:
>> On 2013-08-21 00:38:30 +0000, Andrei Alexandrescu
>> <SeeWebsiteForEmail@erdani.org> said:
>> 
>>> 1. What do we need?
>> 
>> I think D needs less tuples. It has two kinds (language kind and
>> Phobos's kind), which is confusing. It should have just one that covers
>> most use cases.
> 
> Yah, fewer tuples (or assigning distinct names to what we call today such) would be awesome.

That seems like the only thing everyone agrees with. :-)


> I'm unfortunately lost already. I was discussing tuples as in "anonymous structs", not as in "template tuples".

Well, the original post that started this discussion talked about both. I don't think narrowing it only to "anonymous structs" is going to solve the syntax problem as a whole.


>>      int a, b, c, d, e, f;
>>      swap(...(a, c, e), ...(b, d, f));
> 
> This looks like an example taken from a book in which "..." means some stuff is omitted.

Seriously, the major issue with tuples is a conceptual one. No pretty syntax is going to fix it alone. Unfortunately, talking about concepts requires inventing a syntax for them. The syntax then immediately get dismissed as ugly/impractical and no thought is given to what's under it. No wonder this is getting nowhere for the nth time when everyone thinks so superficially.

Just disregard the "..." syntax. It makes sense in the context of my other post. There's no way to appreciate it without that context (and even then, it can surely be improved).

The idea (in my other post) was to un-cripple language-level tuples with one simple fundamental change: allow them to be packed and expanded. With that you can cover 99% of what you want from a tuple struct using the built-in language-level tuple. Plus you can do some other things like the swap of aliases to variables shown above.

There is no reason for template-argument-tuples to be auto-expanding. If you fix that, as I proposed in my other post, you'll almost never need a library struct template to represent a tuple anymore. Thus, fewer tuples.

-- 
Michel Fortin
michel.fortin@michelf.ca
http://michelf.ca

4 5 6 7 8 9 10 11 12 13 14
Next ›   Last »