[Issue 5395] Interval literals
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 12 05:38:32 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5395
--- Comment #4 from Denis Derman <denis.spir at gmail.com> 2011-02-12 05:36:01 PST ---
(In reply to comment #3)
> Michel Fortin:
>
> > how do you rewrite this using the new proposed syntax:
> >
> > auto aa = [iota(a, b, c): 1, iota(d, e): 2];
Annoying. What about reusing '..' instead? Not obvious, sure, but should not
introduce syntactic issues. The initial proposal of ':' is far to be obvious
anyway, I guess.
auto interval = 1..9..2;
auto aa = [a..b..c:1, d..e:2];
Or a single dot (since intervals apply only on ints AFAIK):
auto interval = 1..9.2;
auto aa = [a..b.c:1, d..e:2];
But then we get a lexer ambiguity problem. Could be reinterpreted at
compile-time; still, a bit stupid?
Other solution: group it using (). Either () is part of the interval syntax, or
optional in case of possible ambiguity:
auto interval = 1..9:2;
auto interval = (1..9:2);
auto aa = [(a..b:c):1, d..e:2];
auto aa = [(a..b:c):1, (d..e):2];
I like it (but am not such a fan of saving keystrokes as Bearophile is ;-)
Finally, let it down. Frequence of interval notations in code? Relative
frequence of interval notations requiring a step?
Denis
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list