www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Petition to chime in Issue 1553 - foreach_reverse is allowed for

reply Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
`foreach_reverse` is allowed for delegates and do what `foreach` do thus 
causing dangerous confusion. Walter Bright is the only one for some 
obscure reason definitely for not deprecating this feature and 
WONTFIX-ed the issue. And yes, no big red note in docs about it. As 
always, this is even more error-prone for highly templated language like 
D (i.e. one can expect in template `foreach_reverse` will not compile if 
reverse iteration isn't supported).

Petition for all not indifferent to language misfeatures to chime in and 
show in this thread we all are for deprecating it (if we really are).

Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553

Thanks.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij
Oct 20 2013
next sibling parent Denis Shelomovskij <verylonglogin.reg gmail.com> writes:
20.10.2013 15:29, Denis Shelomovskij пишет:
 `foreach_reverse` is allowed for delegates and do what `foreach` do thus
 causing dangerous confusion. Walter Bright is the only one for some
 obscure reason definitely for not deprecating this feature and
 WONTFIX-ed the issue. And yes, no big red note in docs about it. As
 always, this is even more error-prone for highly templated language like
 D (i.e. one can expect in template `foreach_reverse` will not compile if
 reverse iteration isn't supported).

 Petition for all not indifferent to language misfeatures to chime in and
 show in this thread we all are for deprecating it (if we really are).

 Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553

 Thanks.
Also the funny thing is according to Andrei [1] about `foreach_reverse` over ranges from February 2010: "Gone, that is. Walter agreed to remove it." [1] http://forum.dlang.org/post/hl8345$2b1q$1 digitalmars.com -- Денис В. Шеломовский Denis V. Shelomovskij
Oct 20 2013
prev sibling next sibling parent reply "bearophile" <bearophileHUGS lycos.com> writes:
Denis Shelomovskij:

 Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553
I suggest to keep foreach_reverse in the language, but statically disallow it on delegates. Bye, bearophile
Oct 20 2013
parent reply "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Sunday, 20 October 2013 at 12:33:27 UTC, bearophile wrote:
 Denis Shelomovskij:

 Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553
I suggest to keep foreach_reverse in the language, but statically disallow it on delegates.
+1 foreach_reverse is ugly, but works, and there's no point breaking code just to tidy things up a little. foreach_reverse on delegates on the other hand is completely broken, so should be statically disallowed (preferably with a nice error message explaining that the current behaviour is broken!)
Oct 20 2013
parent Marco Leise <Marco.Leise gmx.de> writes:
Am Sun, 20 Oct 2013 15:55:41 +0200
schrieb "Peter Alexander" <peter.alexander.au gmail.com>:

 On Sunday, 20 October 2013 at 12:33:27 UTC, bearophile wrote:
 Denis Shelomovskij:

 Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553
I suggest to keep foreach_reverse in the language, but statically disallow it on delegates.
+1
+1 Often enough I see code that iterates forwards and backwards over something. foreach and foreach_reverse make the syntax look the same. I don't like the idea of plugging in reverse ranges into foreach to get the same effect. -- Marco
Oct 25 2013
prev sibling next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
20-Oct-2013 15:29, Denis Shelomovskij пишет:
 `foreach_reverse` is allowed for delegates and do what `foreach` do thus
 causing dangerous confusion. Walter Bright is the only one for some
 obscure reason definitely for not deprecating this feature and
 WONTFIX-ed the issue. And yes, no big red note in docs about it. As
 always, this is even more error-prone for highly templated language like
 D (i.e. one can expect in template `foreach_reverse` will not compile if
 reverse iteration isn't supported).

 Petition for all not indifferent to language misfeatures to chime in and
 show in this thread we all are for deprecating it (if we really are).
+1 At a times it looks as if Walter is in favor of keeping whatever broken junk forever just because it was always broken.
 Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553

 Thanks.
-- Dmitry Olshansky
Oct 20 2013
prev sibling next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
On 10/20/2013 01:29 PM, Denis Shelomovskij wrote:
 `foreach_reverse` is allowed for delegates and do what `foreach` do thus
 causing dangerous confusion. Walter Bright is the only one for some
 obscure reason definitely for not deprecating this feature and
 WONTFIX-ed the issue.  ...
This is by design? I thought it was obviously a bug in the implementation.
Oct 20 2013
prev sibling parent "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Sunday, 20 October 2013 at 11:29:38 UTC, Denis Shelomovskij 
wrote:
 `foreach_reverse` is allowed for delegates and do what 
 `foreach` do thus causing dangerous confusion. Walter Bright is 
 the only one for some obscure reason definitely for not 
 deprecating this feature and WONTFIX-ed the issue. And yes, no 
 big red note in docs about it. As always, this is even more 
 error-prone for highly templated language like D (i.e. one can 
 expect in template `foreach_reverse` will not compile if 
 reverse iteration isn't supported).

 Petition for all not indifferent to language misfeatures to 
 chime in and show in this thread we all are for deprecating it 
 (if we really are).

 Issue URL: http://d.puremagic.com/issues/show_bug.cgi?id=1553

 Thanks.
I don't use foreach_reverse and don't intend to. I allowing delegates is error prone if it is just going to do what foreach does.
Oct 20 2013