http://d.puremagic.com/issues/show_bug.cgi?id=5395


Denis Derman <denis.s...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |denis.s...@gmail.com


--- Comment #1 from Denis Derman <denis.s...@gmail.com> 2011-02-09 04:52:39 PST 
---
(In reply to comment #0)
> I suggest for the two following syntaxes to be seen by the compiler as
> equivalent, as syntax sugar of each other:
> foreach (i; 0 .. 10)
> foreach (i; iota(0, 10))
> 
> So I suggest the x..y syntax to become first class and to mean
> std.range.iota(x,y).

+++

> An extension of the interval literal may allow a step value too:
> 
> 0 .. 10:2

Rather doubtful on this; actually topic of your other enhancement request
http://d.puremagic.com/issues/show_bug.cgi?id=4112; see comment there.

> Once present the interval literal becomes useful to remove a () from lazy
> expressions, making them more readable:
> reduce!max(map!foo(1 .. 1000))
> Instead of:
> reduce!max(map!foo(iota(1, 1000)))
> 
> If the interval literal becomes first class, it's possible to use it for 
> ranged
> types, or interval tests too:
> if (x in 5 .. 20) {...}

Yo, just suggested this and the above (both syntaxes are equivalent) on the
mailing list.

> If iota becomes syntax sugar for the ranged sequence, then the compiler is 
> able
> to compile better simple code like this:
> foreach (i; iota(0, 10, 2)) {...}

The important point is that, whatever representation and/or rewriting happens
on the implementation side, on the language side i..j provide range-compatible
semantics (like arrays). It needs not /be/ an instance of Iota (which may also
be rewritten, indeed).

Denis

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to