Can we get rid of opApply?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jan 20 08:36:47 PST 2009
"dsimcha" wrote
> foreach(char[] s; array) vs.
> foreach(char[] s; IntegersAsString(array))
>
> I think a lot of stuff is going to need some kind of extra struct like
> this to
> make it work. When this is the case, it needs to be possible to have a
> default
> iteration method that "just works." The opDot overload, I guess, could do
> this,
> but it's a rather blunt tool, since then you can't use opDot for other
> stuff and
> you'd have to forward _everything_ to the opDot object.
opRange doesn't help here. array is a (non-extendable) primitive, so the
compiler needs to be told how to convert integers to strings.
Even opApply wouldn't get you here.
I actually think something cool would be a toRange struct:
foreach(s; toRange!(string)(array))
Which would be like the to! template.
-Steve
More information about the Digitalmars-d
mailing list