Builtin regex (Was: How to complex switch?)

bearophile bearophileHUGS at lycos.com
Wed May 18 16:36:54 PDT 2011


Andrei:

> One possibility that I hadn't thought before is to use ";" for 
> separating tuple elements. Upon a casual inspection, it turns out no 
> statement can be enclosed directly in "(" and ")" so there's no 
> ambiguity. It would also take care of the issue "did you mean to pass 
> them as function arguments, or as one tuple argument?" Just a thought...
> 
> auto t=(1; "string"; 'c');

If this works, then I like it. In the end having some syntas, any syntax, for tuples is better than not being able to do things like:
auto (foo; bar; _) = spam();
foreach ((a;b); iter1()) {}
int foo(xy@(int x; int y)) { writeln(x, " ", y, " ", xy); // naming whole tuple too
(int x; int y) = (1U; 2U); // conversions


Partially related note: currently this code:

import std.stdio, std.range;
void main() {
    writeln([0, 1, 2, 3, 4]);
    writeln(iota(5));
}

Prints:
[0, 1, 2, 3, 4]
[0, 1, 2, 3, 4]

In Bugzilla I have argued it to print instead:
[0, 1, 2, 3, 4]
[0; 1; 2; 3; 4]

To allow the person that reads the output to better tell apart arrays from lazy sequences.

Thank you,
bearophile


More information about the Digitalmars-d mailing list