View mode: basic / threaded / horizontal-split · Log in · Help
November 07, 2011
Re: Stop TypeTuple as template parameter from expanding
On 11/05/2011 03:23 PM, bearophile wrote:
> Tobias Pankrath:
>
>> I do like it, just it would be nice to have an alternative in phobos, iff there is no other way I am not aware of.<
>
> "Type tuples" (that are allowed to contain more than just types) aren't Phobos constructs, they are built-in in the language.
>
> ----------------------
>
> Christophe:
>
>> You could always make them non-flattening by default, and create an
>> operator to flatten them.
>
> Yeah, but Type tuples are tricky built-in things, with a semantics quite constrained, so I don't know if this is possible.
>
> ----------------------
>
> Dejan Lekic:
>
>> bearophile - I believe it is a matter of taste.
>
> When you design a language most decisions are based on "taste", because there are very few scientific studies on this topic (despite the importance of this field).
>
> A computer language is an interface between a specific implementation of not-tar-pit Turing machine and a partially sentient ape with a brain full of evolutionary design bugs.
>
> The design of programming languages touches low-determinism topics like ergonomy, usability, cognitive psycology, primate instincts, human cognitive skills and capabilities, human senses limits and capabilities, human mind design bugs, etc. So probably designing computer languages can't fully become a field of engineering.
>
> On the other hand trained taste is not arbitrary, and there are negative examples from past languages to learn from.
>
> On the third hand, most of the ideas I show in the D newsgroups turn up being wrong :-)
>
>
>> I actually prefer it the D way because (S, T...) is a TypeTuple as well.
>> (MyList, A, B, C) expands to (A, B, C, A, B, C) so it makes sense that Test
>> prints what it prints. It is all natural to me... It should be like that in
>> my humble opinion.
>
> One of the most hated feature of Perl language is the Auto-flattening of its arrays:
> http://en.wikibooks.org/wiki/Perl_Programming/Array_Variables#Array_Assignment
>
> This anti-feature makes it harder to create nest arrays and in general to create nested structures (that are so natural to do in Python. There are ways to nest arrays in Perl too).
>
> As Christophe notes, it's much simpler to have Python-like lists that nest and then write and use a short recursuive flatten function in the (uncommon) cases it's needed, than trying (and failing) to invent ways to produce some nesting when your data structure auto-flattens :-(
>
>
> If TypeTuples nest, this too keeps being one TypeTuple:
>
> TypeTupleX!(TypeTupleX!(A, B, C), A, B, C)
>
> Bye,
> bearophile

It is _easy_ to put a TypeTuple into a nesting box. (but I have never 
needed to.) Usually you don't want the TypeTuples to nest, so why should 
that be the default?
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home