On Tuesday, 13 July 2010 at 12:39:19 UTC, Steven Schveighoffer wrote:
On Mon, 12 Jul 2010 23:48:05 -0400, Andrei Alexandrescu <[email protected]> wrote:
We've been discussing simplified interfaces in this group but couldn't find one that satisfied all use cases.

Consider this:

T* getNext(R, T)(ref R range, ref T item);

Semantics: <snip>

Yes, yes, yes!

-Steve

Oh dear. I can see this is getting ugly, pretty darn fast...

If you need to /pass/ TWO parameters by _reference_ AND return a pointer to a /templated/ method _just_ to get 1 element out of a range/array, the design is horribly wrong.

Imagine all the sorts of problems newcomers would have with learning this.

Not to mention the troubles /everyone/ would have with having this templated method a class. (How do you override it?)

Really, doing something simple should be simple.

I don't have any brilliant ideas, but one guess would be nullable types... if you can return a nullable value, your interface for an interface could just be:

        T?  next();

and that's it... it would return null if nothing is left. (The compiler can just set the null flag and ignore initializing the rest of the struct if the result is null.)


Anyway, whatever we do... _please_ don't make it something like that suggestion above >_< thanks

Reply via email to