Gregg Irwin napsal(a):
> Hi Ladislav,
>
> LM> hope you don't mind me asking if you noticed the difference in the
> LM> behaviour of the proposed solutions w.r.t. this test?
>
> I don't mind at all! As usual, you have me scratching my head about
> how you come up with your solutions, and how they work (like the first
> two lines in this one). ;)
>   
first two lines: the first line is there just to shorten the second one. 
We could have used only the second line as follows:

    emit: first use reduce [emit] reduce [reduce [emit]]

This idea is not new, you could have seen it in 
http://www.fm.tul.cz/~ladislav/rebol/build-func.r. (I even remember it 
being discussed on this ML some time ago.)

Explanation: we create a new context containing just one word having the 
spelling of the EMIT argument and set the 'emit word to refer to the new 
context word doing it carefully enough to suppress possible conflicts as 
well as undesired evaluations.
> I'm sure I can adapt to the function syntax, if that's what Carl
> eventually chooses, or what we come up with as a "standard" COLLECT
> function, even if it doesn't get into R3.
>   
Your COLLECT dialect surely is a nice and interesting idea and deserves 
more attention than it received until now.
>     collect: func [
>         [throw]
>         {Collects block evaluations.}
>         'emit "Yield-function name"
>   
maybe "Emit-function name" ?
>         block [any-block!] "Block to evaluate"
>         /into dest [series!] "Where to append results"
>         /only "Insert series results as series"
>     ] [
>         emit: reduce [emit]
>         emit: first use emit reduce [emit]
>         use [dst] copy/deep [
>
> ; Why "make block! []" rather than "copy []"?
>   
actually, because of copy/deep above, it is sufficient to use

    dst: any [:dest []]

(at least I hope so)
>             dst: any [:dest make block! []]
>
> ; Do we want to refactor the duplicate func body into something like
> ; this:
>             set emit func [value [any-type!]] head insert
>                 [tail :dst get/any 'value   get/any 'value]
>                 pick [insert insert/only] not only
> ; or this:
>             set emit func [value [any-type!]] append copy either only
>                 [[insert/only]] [[insert]]
>                 [tail :dst get/any 'value   get/any 'value]
> ; They aren't as clear to the casual reader, like our original ROUND
> ; func is not as clear as your improved one that uses CASE.
>   
I slightly prefer readability, but it does not matter much.
>             do bind/copy block emit
>             head :dst
>         ]
>     ]
>
>
> Does anyone else have any comments, WRT returning HEAD or not,
> Ladislav's note about a SET-like syntax, or Gabriele's version?
>
>
> -- Gregg                         
>
>   

Gabriele's version looks less comfortable and less reentrant than this 
one, otherwise it may be a matter of preferences.

-L

-- 
To unsubscribe from the list, just send an email to 
lists at rebol.com with unsubscribe as the subject.

Reply via email to