Builtin regex (Was: How to complex switch?)

Timon Gehr timon.gehr at gmx.ch
Wed May 18 06:11:44 PDT 2011


> Timon Gehr:
>
>> Tuple literals would indeed be very nice.
>
> I have asked for tuple unpacking syntax (and other things like some support from
the type system). Tuple literals are less needed.
>
>> (having syntactic sugar for phobos functionality in the language
>> seems like a very bad design to me,
>
> I don't see it as a bad design. Why do you see it as a bad thing?
Library code should make use of the language to implement its semantics.
Not the other way round. They also screwed this up in C++0x with
std::initializer_list;

>
>
>> However, tuple literals break the comma operator...
>
> If something like a banana bracket syntax (|...|) is required (or some other
kind of thing), then I think it doesn't clash with C usages of comma operator.

It does not clash with any other language feature because it is too ugly to have
been considered as syntax for another language feature :). imho it would not be
syntactic sugar anymore, that looks awful and is awful to type. Just my opinion
though. Another reason I dislike it: it looks different to other "tuple literals"
that are already built-in:

foo (note, how, this, is, a, tuple, "!");

>
>> What would be the type of such a tuple literal? (T,T,T,...)?
>
> I presume Tuple!(int, int, int)

It would have to be a built-in type. (Even if it is internally just implemented as
Tuple hanging around in druntime).

>
>
>> I don't expect something like this to be implemented soon though.
>
> Stuff like this requires months of thinking, and just few days to be implemented
by Walter :-)

If it is just some simple rewrites it should indeed be possible to implement it
quite fast. Still, I think (|1,2,3|) is not optimal.

Maybe the best way to resolve it would be to allow some special symbol as an
identifier, so that the library/user could make that symbol an alias of "tuple".
It would have to be a very small symbol, are there any suitable symbols that are
not yet taken?


>
> Bye,
> bearophile

Timon


More information about the Digitalmars-d mailing list