MiniD 2 - Tentative Release Candidate 1

davidl davidl at 126.com
Tue Dec 9 21:12:44 PST 2008


在 Tue, 09 Dec 2008 21:07:46 +0800,Jarrett Billingsley <jarrett.billingsley at gmail.com> 写道:

> On Tue, Dec 9, 2008 at 3:58 AM, davidl <davidl at 126.com> wrote:
>> I've learned a bit minid today.
>>
>> I'm curious why foreach opApply don't use the yield instead of the current implementation?
>
> Ah, but you can.  Coroutines have an opApply, and are therefore
> iterable using foreach.  See the section on coroutines
> (http://www.dsource.org/projects/minid/wiki/LanguageSpec2/Functions#Coroutines)
> for some info on that.  Using coroutines for iteration is more
> powerful, but of course the price you pay is that they're a lot more
> expensive than a function closure.
>

I got an impression that a scripting lang coroutine is less expensive than a function call? I guess coroutine in a scripting interpreted lang won't require any thread involved, and the suspension of the execution maybe even more costless compared to a return statement and reexecution of that function in the case of opApply.
And I'm still not able to get opApply to work with coroutines, any example available?
I always get the error message of "Iterated coroutine must be in the initial state", I've no clue about what it's going on.

>> and another curious thing is how can I serialize/deserialize minid object in minid?
>> any .tupleof for class available?
>
> Sure, have a look of fieldsOf/allFieldsOf in the base library
> (http://www.dsource.org/projects/minid/wiki/StdLib2/BaseLib).  They'll
> give you functions as well, but it's easy to skip over them.
> 

thanks, that's helpful. MiniD is way more powerful than I've thought.


More information about the Digitalmars-d-announce mailing list