Re: Class and Iterator Design Question



Eric Mahurin ha scritto:

I believe that's the plan. I think all the standard

iterators are


going to start returning enumerator objects when called

without a block.

James Edward Gray II

would'nt it make more sense to have yield work coroutinish
when called withouth a block, basically integrating the enumerator
functionality in it?


That sounds unnecesarily complex.  If it is what I think you
are talking about, you'd return some kind of object with a
continuation when you hit a yield without a block (like a
generator?).  An example would help explain what you are
talking about.
>
> I think the current plan with Enumerators sounds better.

My apologize, I actually meant "Generator" not "Enumerator".

Anyway, yes, just like a Generator, and for all the usage of yield, not just for Enumerables.
This, in my opinion, would be more consistent and preserve the semantic of yielding better than returning an Enumerator, but it seem this decision was already taken in the direction you like, judging from a recent patch.



.



Relevant Pages

  • Re: foreach enhancement
    ... It is a sequence generator which is expressed by ... to define behaviour based on syntax instead of semantics. ... automated input on expressions typed IEnumerable explicitly instead of any ... > and for more complicated things I would create my own enumerator. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Class and Iterator Design Question
    ... >>>would'nt it make more sense to have yield work coroutinish ... >> generator?). ... > of yielding better than returning an Enumerator, ... If you want external iterators, I don't think Generator is the ...
    (comp.lang.ruby)
  • Re: Cleaner syntax for .map (is there already a way, or ruby2 idea?)
    ... Trans wrote in: ... } I know that people.every could return some kind of generator or enumerator, which could then be fed "email_addr" symbolically... ... David A. Black dblack@xxxxxxxxxxxx ...
    (comp.lang.ruby)
  • Re: recursive GetEnumerator()
    ... var enumerator = self.GetEnumerator; ... public IEnumeratorGetEnumerator() ... thats the nature of yield I beleive, however this is the first time ... the code inside the foreach loop with the value in expresion ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Forevery() writable iterator mechanism in C# 3
    ... clarifying that issue for me (a writable sequencer vs a read only enumerator). ... Currently you can not pass ref and out arguments to an iterator ... Why would the interface need ref/out itself? ... collection at all - that's really a major point of "yield", ...
    (microsoft.public.dotnet.languages.csharp)

Loading