[Issue 8727] __traits(is_reserved_word, "") ?

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Sep 26 08:51:31 PDT 2012


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


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra at gmail.com


--- Comment #3 from monarchdodra at gmail.com 2012-09-26 08:52:13 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > https://github.com/D-Programming-Language/dmd/pull/1144
> 
> Thank you, only 45 minutes to see implemented one enhancement request of mine
> :-)
> 
> (Regarding the comments inside your patch, "foreach_reverse" is quite useful.
> retro() will be acceptable only if the compiler recognizes it as special and
> guarantees to implement it with the the same efficiency of foreach_reverse in
> all cases. I think this will not happen, so I'll try to keep "foreach_reverse"
> inside the language.)

I don't want to hijack this pull request into off topic discussion, but is
foreach_reverse *really* scheduled for deprecation? Or is this just an ongoing
suggestion. If it is an ER, do you have a link to it?

IMO, The problem with retro is that it does not support natural slice syntax:

--------
import std.range;
import std.stdio;

void main()
{
    foreach_reverse(i; 0..10)
      writeln(i, "...");
    writeln("Fire!");

    foreach(i; retro(0..10)) //NOPE
      writeln(i, "...");
    writeln("Fire!");
}
--------

The equivalent code would require inserting an iota. Either from 9 to -1 (ew),
or from 0 to 10, then reversed (blargh):

--------
void main()
{
    foreach_reverse(i; 0..10)
      writeln(i, "...");
    writeln("Fire!");

    foreach(i; iota(9, -1, -1)) //Ew
      writeln(i, "...");
    writeln("Fire!");

    foreach(i; iota(0, 10).retro() ) //Blargh
      writeln(i, "...");
    writeln("Fire!");
}
--------

Looking only at the syntax, I'd like to keep foreach_reverse thankyou very
much. I also doubt that the performance is anywhere near the same level.

-- 
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