r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

[unknown: 5]
21-Jan-2009
[12104x4]
My point is that REBOL is not consistent.
Why can I do a find using a lit-word but not get results when using 
the lit word from a block?
find a 'test works but find a first c doesnt.
I would have to use find a to-word first c to get a match.
Pekr
21-Jan-2009
[12108x3]
I think it is a bug. But we will probably see gurus trying to find 
an excuse, why sometimes you can't code in REBOL different way than 
to simply try some stuff in console ...
And - imo if RT would post some formal specification to the language, 
we could fix some gotchas and surprises, not trying to find academic 
theories, why it work certain way ...
insert as an operation does not preserve datatype. It reduces litword 
to word. Not sure there is a reason to do so ...
[unknown: 5]
21-Jan-2009
[12111]
Yeah, that to me would be a bug.
Henrik
21-Jan-2009
[12112]
>> append [] to-lit-word 'a
== ['a]
[unknown: 5]
21-Jan-2009
[12113x2]
Yeah Henrik but that is a workaround really.
the 'a was already a lit-word to begin with.
Pekr
21-Jan-2009
[12115x2]
Henrik - but - that is exactly the excuse I was talking about
why should I use to-whatever for one datatype, but not for the other 
one?
Henrik
21-Jan-2009
[12117x2]
the question is probably which operation is more common.
I'd bet Carl did it that way, because it is something he does more, 
than the other way around.
Pekr
21-Jan-2009
[12119]
hmm, but it can really lead to surprises, as Paul got - trying to 
find something by reference ....
[unknown: 5]
21-Jan-2009
[12120]
To me it is one of the exceptions to the rule things.  With REBOL 
you gotta have all these exceptions to the rule.
Henrik
21-Jan-2009
[12121]
I'm not defending it, just trying to come up with a theory.
Pekr
21-Jan-2009
[12122]
... but yes, REBOL is dynamic, so it might be a problem, to have 
all cases working as expected ...
[unknown: 5]
21-Jan-2009
[12123]
lol
Henrik
21-Jan-2009
[12124]
because I know that Carl works alot more with cases of usage rather 
than theoretical correctness, as long as the result isn't completely 
backwards/illogical.
[unknown: 5]
21-Jan-2009
[12125]
Well, at least I know how to get around it which is why I just mentioned 
that it "bothers me".
Pekr
21-Jan-2009
[12126]
Now someone clever should answer, if it would have some consequences 
to not reduce lit-word upon block insertion?
[unknown: 5]
21-Jan-2009
[12127]
But to me Henrik the append or insert should be able to look at the 
argument and see it is already a lit-word and append it as such.
Henrik
21-Jan-2009
[12128x2]
I was going to write something clever about that, but I think trying 
to fit such a change in has some pretty big ramifications for how 
words are used in REBOL. :-)
anyhoo, I can't defend it, so I'll let BrianH take over.
[unknown: 5]
21-Jan-2009
[12130x3]
Heh.
Well at least you didn't try to give excuses.
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
[12152x2]
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]
]