World: r3wp
[!REBOL3-OLD1]
older newer | first last |
BrianH 1-May-2006 [801x5] | Ladislav, it's not that I don't see the advantage to closures in principle, and that I wouldn't use them occasionally if they were there. It's that Carl's description of how the closures would be implemented seems a little heavyweight, largely as a result of REBOL's direct binding. I would use closures, but only when creating my own contexts manually or copying a subset of the data would not have the efficiency gains they would normally have. |
I will check out your build dialect though - it sounds interesting. | |
I found one bug: Your build dialect will convert lit-path! to path! unintentionally (as far as I can tell). Convert all word references to block or result in your inner function to get-words (:block and :result respectively). | |
;The changed build function would be: build: func [ {Build a block using given values} block [block! paren! path! lit-path! set-path!] /with values [block!] /local context inner ] [ values: any [values [only: :encl ins: :dtto]] context: make object! values inner: func [block /local item item' pos result] [ result: make :block length? :block parse block [ any [ pos: set item word! ( either all [item': in context item item <> 'self] [ change pos item' set/any [item pos] do/next pos insert tail :result get/any 'item ] [insert tail :result item pos: next pos] ) :pos | set item get-word! ( either all [item': in context item item <> 'self] [ insert/only tail :result get/any item' ] [insert tail :result item] ) | set item [ block! | paren! | path! | set-path! | lit-path! ] ( insert/only tail :result inner :item ) | set item skip (insert/only tail :result get/any 'item) ] ] :result ] inner :block ] | |
Sorry, missed one after parse ;( | |
Ladislav 2-May-2006 [806x2] | thanks, incorporating your correction |
http://www.fm.vslib.cz/~ladislav/rebol/build.ris now corrected according to the Brian's suggestion | |
BrianH 2-May-2006 [808] | You need to change all of the insert tail result to insert tail :result to keep the result from being converted from a lit-path! to a different path! every time. |
Ladislav 2-May-2006 [809x4] | correcting, thanks |
this lit-word and lit-path behaviour does not look very natural to me | |
although insert tail result may be OK anyway? | |
>> result: first ['a/b] == 'a/b >> insert tail result 's == >> :result == 'a/b/s | |
BrianH 2-May-2006 [813x2] | That means that the path! returned by DOing a lit-path! returns the same data rather than a copy. Interesting. |
Undocumented too. I've found that lit-word! works the same way. | |
Ladislav 2-May-2006 [815] | this is the property I called Relatives in http://www.fm.tul.cz/~ladislav/rebol/identity.html |
BrianH 2-May-2006 [816] | Still, changing them would make your build dialect compatible with older versions of REBOL that evaluated path and paren values when you referenced them with a word rather than a get-word. It all depends on how far you value backwards compatibility. |
Ladislav 2-May-2006 [817] | yes, I am making the change |
BrianH 2-May-2006 [818] | I remember when they changed that they said that very little REBOL code depended on the old behavior, and yet I had to change some of mine as I recall. Apparently their mileage did vary. |
Ladislav 2-May-2006 [819x2] | http://www.fm.tul.cz/~ladislav/rebol/identity.htmlposted |
sorry, I mean http://www.fm.vslib.cz/~ladislav/rebol/build.rposted | |
BrianH 2-May-2006 [821] | I guess your Relatives are like as-binary and as-string too. |
Ladislav 2-May-2006 [822x2] | yes, that is it |
(but I wrote that before AS-STRING and AS-BINARY existed), so I used just PARSE and DISARM to illustrate this property) | |
BrianH 2-May-2006 [824] | Looks good to me, although it is somewhat amusing to see SciTE's syntax highlighting getting confused about the word context. |
Ladislav 2-May-2006 [825x2] | ah, you are using SciTE? |
(I am using PSPad, but wanted to give a try to SciTE) | |
BrianH 2-May-2006 [827] | Sure. I prefer Notepad++ but it doesn't have REBOL enabled as a language. What's with the IN patch? |
Ladislav 2-May-2006 [828] | in later version the IN function didn't accept any-word as argument |
BrianH 2-May-2006 [829] | It seems to here, 1.3.2.3.1 |
Ladislav 2-May-2006 [830] | sorry, I wanted to say, in older versions of interpreter |
BrianH 2-May-2006 [831x4] | Here's a good installer for SciTE on Windows: http://gisdeveloper.tripod.com/scite.html |
I've been meaning to improve SciTE's REBOL support, but I'm waiting to see what changes REBOL 3 will bring. | |
After that I can hack Notepad++ to add the support there too. | |
One of your examples is wrong: build [only reduce [3 * 4 5 + 6]] ; == [[12 11]] | |
Ladislav 2-May-2006 [835x3] | testing |
aha, yes, missing block brackets | |
example result corrected | |
BrianH 2-May-2006 [838] | Well, this has been fun, but I must go for now. I look forward to future collaborations :) |
Ladislav 2-May-2006 [839] | thanks |
Henrik 2-May-2006 [840] | 3 new entries in the blog |
Geomol 2-May-2006 [841] | Henrik, good suggestion with the loop working on more than one series (in your reply to Carl's blog). That must be possible with a function definition. But it should probably be part of REBOL, at least a mezzanine. |
Henrik 2-May-2006 [842x2] | I realized that it's not possible with FOREACH since it would need to know the difference between two and three blocks as input (don't know if a refinement would take care of that) |
but I use this a lot and it would make it easier to interlace many blocks this way | |
BrianH 2-May-2006 [844] | A new mezz, formany perhaps? |
Henrik 2-May-2006 [845] | I got another idea. Please see the blog. |
BrianH 2-May-2006 [846] | Henrik, try to implement your ideas in REBOL code. Post it to AltME if you need help. Let us hash out the details, improve it. If it turns out well, it could become a mezzanine function. |
Henrik 2-May-2006 [847] | alrighty then |
BrianH 2-May-2006 [848] | Someone mentioned Ladislav's build dialect, and look what happened to it... ;-) |
Henrik 2-May-2006 [849] | haven't even followed it, but it seems that Carl likes it |
Gabriele 2-May-2006 [850] | noone remembers my nforeach function? :) |
older newer | first last |