opSlice() magic for foreach now works?
Steven Schveighoffer
schveiguy at yahoo.com
Wed Mar 30 08:34:18 PDT 2011
On Wed, 30 Mar 2011 11:29:02 -0400, spir <denis.spir at gmail.com> wrote:
>
> Strange, I just tried it on a custom, trivial, collection type
> --precisely to verify that it does not work only for the standard
> SList-- and it worked fine (dmd 2.051 on ubuntu). But now I cannot
> reproduce this success anymore! get the same error as you. Will go on
> trying and tell you if anything changes.
>
> Anyway, if the feature is still unimplemented, why and how does foreach
> work on SList. ???
It may be partially/poorly implemented. I looked at the disassembly, and
it is indeed calling opSlice and the range primitives inside the foreach
loop.
There is likely a trigger that the compiler uses to determine if it can do
that, and the trigger is probably incorrectly defined.
I would think (though I'm not a compiler guy) that to fix this should be
minor since the code generation already works in at least one case.
Walter?
-Steve
More information about the Digitalmars-d
mailing list