World: r3wp
[Core] Discuss core issues
older newer | first last |
[unknown: 5] 21-Jan-2009 [12132] | Thanks Henrik. |
BrianH 21-Jan-2009 [12133] | It's not the insert that changes the litword to a word, it is the initial evaluation of the litword. By the time insert sees it it's already a word. |
[unknown: 5] 21-Jan-2009 [12134] | But couldn't insert be modified to see that it is appending a lit word to a block and make the appropriate modification? |
BrianH 21-Jan-2009 [12135] | INSERT wasn't appending a lit-word, it was appending a word. DO converted the lit-word to a word, not INSERT. |
[unknown: 5] 21-Jan-2009 [12136x3] | In the example, I gave I showed that b was a lit-word being appended to a. |
well at least in my understanding of it. | |
But I already get the idea. That the idea is that it it is now a word and not a lit-word! | |
BrianH 21-Jan-2009 [12139] | No, it was an expression of the words append and a and a lit-word 'b. DO evaluated the expression, and while doing so evaluated the 'b to create b. Then it passed the b to the function referenced by the word append. |
[unknown: 5] 21-Jan-2009 [12140] | Back to this issue, I checked replace and it doesn't support replacing word! in a block with lit-words. |
BrianH 21-Jan-2009 [12141] | Code? A lit-word is an active value, like a function. You need to use get-word references if they are assigned to variables, or to-lit-word if they are literal in a place where they will be evaluated. |
[unknown: 5] 21-Jan-2009 [12142] | I'm moving on from that issue. I'll wait and consider R3. But these pitfalls have already got me into other languages. |
BrianH 21-Jan-2009 [12143] | R3 is no different from R2 when it comes to lit-words. REPLACE is the same in both too. |
[unknown: 5] 21-Jan-2009 [12144] | Yeah was figuring that would be the case. |
BrianH 21-Jan-2009 [12145x3] | That's funny, other languages' pitfalls get me more into REBOL. |
REPLACE is safe for active values, so it definitely will allow you to replace words with lit-words, as long as you actually pass it lit-words. | |
This is true for R3 and 2.7.6+ at least. | |
[unknown: 5] 21-Jan-2009 [12148x2] | Not an issue really. Good think about REBOL is you can usually find a workaround. |
I just noticed this group is web-public. Shouldn't this be a bit more closed as often bugs and such are discussed here. | |
Sunanda 21-Jan-2009 [12150] | Given RAMBO, the R2 bug database, is web available it should not be too much of a problem: http://www.rebol.net/cgi-bin/rambo.r |
[unknown: 5] 21-Jan-2009 [12151] | I think what Brian is saying is that it isn't a bug issue. Just a gotcha. |
BrianH 21-Jan-2009 [12152x4] | I make it a point to not discuss bugs with security implications in web-public groups. Otherwise it is better to let people know. |
BACKPORTS! Hot off the presses! Get your new R3 functions, now here for R2! Available now, before the next release! funct: make function! [ [catch] "Defines a user function assuming all set-words are locals." spec [block!] "Help string (opt) followed by arg words (and opt type and string)" body [block!] "The body block of the function" /local r ws wb a ][ spec: copy/deep spec body: copy/deep body ws: make block! length? spec parse spec [any [ set a [word! | refinement!] (insert tail ws to-word a) | skip ]] wb: copy ws parse body r: [any [ set a set-word! ( unless find wb a: to-word a [insert tail wb a] ) | hash! | into r | skip ]] unless empty? wb: difference ws wb [ remove find wb 'local unless find spec /local [insert tail spec /local] insert tail spec wb ] throw-on-error [make function! spec body] ] functor: make function! [ [catch] "Defines a user function with all set-words collected into a persistent object (self)." spec [block!] "Help string (opt) followed by arg words (and opt type and string)" body [block!] "The body block of the function" /local r wb a ][ ; Note: Words in the spec override the bindings of the object words. wb: copy [] parse body r: [any [ set a set-word! (unless find wb a [insert tail wb a]) | hash! | into r | skip ]] remove find wb [self:] throw-on-error [make function! copy/deep spec bind/copy body construct wb] ] | |
Obviously the R3 versions are faster, smaller and more efficient, but the meaning is the same. And you can use them now in R2. | |
The first, FUNCT, implements Ruby-style local variables without any explicit declaration needed. The second implements static locals. | |
Steeve 21-Jan-2009 [12156x2] | we need FUNCTARD which converts all words in locals. |
(joke) | |
BrianH 21-Jan-2009 [12158] | *TARD indeed, because such a function wouldn't be able to call external functions, not even DO :) |
Steeve 21-Jan-2009 [12159x2] | ahah... |
arghhh... rebdev is bugging.... Carl what have you done !!!!???? :-) | |
BrianH 21-Jan-2009 [12161] | It might interest you to know that all event handlers in the R3 GUI are created with the R3 version of FUNCT. |
Steeve 21-Jan-2009 [12162] | event handlers are my next assignement i have some new ideas too |
BrianH 21-Jan-2009 [12163] | They are declared as code blocks in R3, not functions, and then turned into functions using a fixed spec and FUNCT. Safer that way. |
Steeve 21-Jan-2009 [12164x3] | like actors in scheme i begin to know well that behavior |
btw, i know some optimisations on the make-port intrinsic function, it's an old one currently | |
humm... what i said is not clear | |
[unknown: 5] 21-Jan-2009 [12167] | Static locals. I love it. |
BrianH 21-Jan-2009 [12168] | R3 has changed SET to allow [set-word:] arguments so that they can be used with functions like FUNCT and FUNCTOR. R2 not (yet?). |
[unknown: 5] 22-Jan-2009 [12169] | Cool functions Brian. |
BrianH 22-Jan-2009 [12170] | Yeah, I wrote them this evening (with helpful criticism from Steeve. I also wrote the R3 version of FUNCTOR. |
[unknown: 5] 22-Jan-2009 [12171x3] | Excellent, maybe these need to be added to list in the 2.7.7 world. |
forgot the name of that world. | |
r2-beta is that world. | |
Janko 22-Jan-2009 [12174x6] | Rebol looks totally consistent to me in Paul's example above, the key to that result is that rebol doesn't automatically evaluate (reduce) blocks -- which is the key properti of rebol that makes most of it's things possible. This is how I see it : |
>> b: 'test ;; line gets evaluated , b already holds a word! == test >> append a :b ;; word get's added to serries == [test] >> type? first a == word! >> find a 'test ;; 'test get's evaluated into a word again so find finds it in block == [test] >> c: ['test] ;; 'test is in a block and of course doesn't get evaluated as any other thing in a block wouldn't so it stays lit-word! == ['test] | |
if you want a block to get evalueated you should reduce it, then it will also find it | |
>>c: reduce ['test] | |
or >>c: [test] | |
BrianH and others : you made such great word (and ported it to mezzaine - I still have no idea what that is :) ) of the word map (as in functional programming ) ... did you maybe or is there any chance that its sister function reduce or fold or fold-left could be made in such a way.. I use your map a lot now but I have to use my poor fold word for folds :) | |
Will 24-Jan-2009 [12180] | on OS X and Linux, for every instance of rebol , 2 processes are launched, the second for dns, right? is there any known bug? I have an difficult to debug situation , when quitting cheyenne after some load, some handler process goes 100% cpu, but the dns process is no more there, this make me think it may be a problem with rebol, otherwise also if one process would go 100% CPU, the dns one would still be present, help!! 8) |
Will 25-Jan-2009 [12181] | I'm not sure I understand what call/show introduced in 2.7.6 does? |
older newer | first last |