Help With Query
[1/10] from: RJBywater::aol::com at: 19-Feb-2004 17:17
Hello, I am a complete newbie with Rebol having just recently downloaded Rebol/Core and started playing with it. According to the rebolcore online book, given the following code root: [sub1 [sub2 [ word "a word at the end of the path" num 55 ] ] ] path: 'root/sub1/sub2/word then entering probe path should yield "a word at the end of the path" but when I enter it I get instead is root/sub1/sub2/word as shown below
>> probe path
root/sub1/sub2/word == root/sub1/sub2/word Have I misunderstood what should be happening? Many thanks in advance Ron Bywater
[2/10] from: ammon:addept:ws at: 19-Feb-2004 15:36
The problem you are experiencing here is the difference between a path! and a lit-path!. changing the line: path: 'root/sub1/sub2/word to: path: root/sub1/sub2/word will make it function as you expected. using a lit-path! will force the interpreter to NOT evaluate the path. NOTE: The difference between a lit-path! and a path! is simply that a lit-path! has a single quote in front of it whereas a path! does not. You will find that word! and lit-word! work the same way. Use a lit-path! or a lit-word! where you want the LITERAL word or path rather than the value that it may refer to. HTH ~~Ammon ;~>
[3/10] from: hallvard:ystad:oops-as:no at: 19-Feb-2004 23:47
Hi Ron, Omit the tick before the path string:
>> path: root/sub1/sub2/word
== "a word at the end of the path" That does the trick. The tick indicates that you're talking about the path, not whatever the path would represent. See? HY Dixit [RJBywater--aol--com] (23.17 19.02.2004):
[4/10] from: SunandaDH:aol at: 19-Feb-2004 17:46
Welcome to REBOL, Ron. It's a lot of fun. Once you get your head around some of the strangeness, it all starts to make more sense than you can imagine -- or, occasionally, explain. Ron:
> Have I misunderstood what should be happening?
What Ammon says. Though I still find these sorts of things confusing even after a couple of years. The only way I know to make your code work is this: root: [sub1 [sub2 [ word "a word at the end of the path" num 55 ] ] ] path: 'root/sub1/sub2/word do reduce [path] == "a word at the end of the path" Enjoy playing! Sunanda.
[5/10] from: maximo:meteorstudios at: 19-Feb-2004 17:59
> -----Original Message----- > From: [RJBywater--aol--com] [mailto:[RJBywater--aol--com]] > Hello,
> I am a complete newbie with Rebol having just recently
you'll find this list very welcoming! you have it almost right!
> given the following code > > root: [sub1 [sub2 [ > word "a word at the end of the path" > num 55 > ] ] ] > path: 'root/sub1/sub2/word
use path: root/sub1/sub2/word the ' character is telling rebol not to interpret the path you gave it, just to store it. in fact this is usefull, if you want to use the path later on, but do not have the data handy yet! -MAx
[6/10] from: RJBywater:aol at: 19-Feb-2004 18:16
Hello, Thank you for the responses. I'm still confused however (that's nothing new!). If a variable is of type path! should it not display what it is pointing to? The documentation that I have looked at certainly indicates that so I am suprised to have to issue do reduce [path] to get the string "a word at the end of the path" I apologise if I seem a bit dense. Perhaps I am trying to run before I can walk. Kind regards Ron
[7/10] from: ingo:2b1 at: 20-Feb-2004 0:39
Hi Ron, welcome to the fun of rebol :-) and the headache with its documentation :-( but I didn't say that ;-) Actually, the core guide is not 100% up to date, and you stumbled over one of its shortcomings. Your code worked in core 2.5.0, but since then evaluation of paths has changed, so you have to use the trick Sunanda has shown now. BTW, could someone on the /View 1.3 world _please_ add a bug that do 'a/lit/path still doesn't work? That was what Carl promised to reduce those paths now. Kind regards, Ingo [RJBywater--aol--com] wrote:
[8/10] from: maximo:meteorstudios at: 19-Feb-2004 18:41
>> type? 'this/is/a/path
== path! which means when evaluating a lit-path it returns a path same thing for word! and lit-word! you must then evaluate the path to get the data it points to. To evalute a path you must use 'DO and include the path in a block. I don't know why 'DO won't evaluate a path directly... I think we can assume that to be a limitation (bug ;-). HTH! -MAx PS: people on this list often use the tick mark within the text to identify rebol words and functions (like with 'DO above). but generally do not actualy include the tick when typing the word on the command line... ;-)
[9/10] from: hallvard:ystad:oops-as:no at: 20-Feb-2004 0:46
Dixit [RJBywater--aol--com] (00.16 20.02.2004):
>Hello, > >Thank you for the responses. I'm still confused however (that's nothing >new!). If a variable is of type path! should it not display what it is pointing to?
Yes. But when you write 'root/sub1/sub2/word, it's not a path!, it's a lit-path!. The little preceeding tick (') makes all the difference.
>I am >suprised to have to issue do reduce [path] to get the string "a word at the end of >the path"
Nope. Just remove the tick and you're there. Regards, HY PS. You'll find this list a wonderful place to get help. Don't feel dumb, just come along with your questions, and don't bother reading all the 300 responses when they go off into something theoretical aside your question... Some of the first responses usually replies adequately.
[10/10] from: ingo:2b1 at: 20-Feb-2004 0:45
Hi Ron, it's not you, but Rebol docs, which aren't able to cope with rebols pace :-) (See my other post I just sent). Just one more thing about the change to less aggressive evaluation: before the change it was not possible to hand over a path to another function, because it always was reduced and the _value_ that path was pointing to was handed over (the way the docs describe it, and it feels natural), now it is a little headache to get to the value (though this should be temporarily), but handing a path a=F6=F6 by itself is possible too. All in all, it seems like a win if you need it (and the times will surely come ;-) Kind regards, Ingo [RJBywater--aol--com] wrote: