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

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

Chris
13-Sep-2007
[857]
path: 'foo/bar
join path 'ton ; ??
RobertS
13-Sep-2007
[858]
fails with 
  ** Script Error: Cannot use path on word! value
Chris
13-Sep-2007
[859]
Hmm, works here.
RobertS
13-Sep-2007
[860x2]
to-path reduce[path 'word]   ; works OK but what a klunk
Only if the blocks are literaly embedded.
Could you try with the example
  t1
  t2
Chris
13-Sep-2007
[862]
join to-path 't2 't1
RobertS
13-Sep-2007
[863x3]
no, in the example that I posted above :-)
>> t1: [a "one" b "two" c "three"]

>> t2: [f t1]
'f has no value so it is just like a functor
I am not askeing to be able to just use
   t2/f/a
with no further ado
I must build the path
   newPath: to-path reduce [ t2/f  'a]

is a pain ( and only because of how to-path is implemented;  to-lit-path 
is no more help as far as I can see at this hour
Chris
13-Sep-2007
[866x2]
I'm not sure why -- newPath: join 't2/f 'a -- doesn't work...
Hold on, -- join to-path t2/f 'a --??
RobertS
13-Sep-2007
[868x2]
That just caused Rebol 2.6.3 to blow away
I did not send teh missuve to Microsoft that I was proffered
the missive
Chris
13-Sep-2007
[870]
It works on 2.6.2 (Mac) 2.7.5 (Win)
RobertS
13-Sep-2007
[871x2]
let me fire up Rebo/View again
but how will this help me where I have a WORD that is holding that 
initial, partial, path ?
Chris
13-Sep-2007
[873x2]
join to-path do path 'a
path: 't2/f
do join to-path do path 'a
RobertS
13-Sep-2007
[875x2]
;same error
>> t1: [a "one"]
== [a "one"]
>> t2: [f t1]
== [f t1]
>> pp: join 't2/f 'a
== t2/f/a
>> do pp
** Script Error: Cannot use path on word! value
** Where: halt-view
** Near: t2/f/a
>>
2.6.3 just ditched me again with that one ...
Chris
13-Sep-2007
[877]
This is the limitation of evaluating paths.  'do does not evalute 
't1 when it is returned from 't2/f
RobertS
13-Sep-2007
[878x2]
I think 2.6.3 does not want 'path used as a word ;-)
so do you think that   
   to-path reduce [ my-path  'my-next-refinement]
the best that I can do?
Chris
13-Sep-2007
[880]
If your interpreter chokes on 'join, then I guess so...
RobertS
13-Sep-2007
[881x4]
I could try just Rebol/Core and see if that make a difference

It is not very often that Rebol blows out on me ... I can't remember 
when last before I started looking at my functor issues
That's 3 times tonight with only 2 teeny blocks and 2 paths  and 
no do against any file and nothing added to user.r
ah-ha !
Works fine in Rebol/Core  ! 

path: 't2/f
do join to-path do path 'a
Nope.

Back to View and this time Rebol did not blow out of the water .... 

Is there a dump.log that I can look at see what these fatal errors 
have been ?
Chris
13-Sep-2007
[885]
Not sure.  Try working with -- trace on
RobertS
13-Sep-2007
[886]
>> t1: [a "one"]
== [a "one"]
>> t2: [f t1]
== [f t1]
>> path: 't2/f
== t2/f
>> do join to-path do path 'a
== "one"
; thanks CHRIS
Chris
13-Sep-2007
[887]
Hey, if it works : )
RobertS
13-Sep-2007
[888]
I would not have stumbled on the 
   do path
any too soon, I fear ... ;-)
Chris
13-Sep-2007
[889]
It's not the most intuitive move, for sure.
RobertS
13-Sep-2007
[890x7]
I am adding 
   augpath: func [{augment path with a word}
to my armory
Now to find out what typo of mine is able to blow 2.6.3 outa the 
wadder
augpath: func [{ augment a PATH with a WORD }path 'word] [
      return join to-path reduce[path] :word]
; augpath t2/f a
oops!
IGnoring the needless return,  that is one word longer than

>> pword: func [path 'word /local blk] [
    to-path reduce[path :word]]
; ;-)
; I mean
 augpath: func [path 'word ] [
    to-path reduce[path :word]]
; but IN the interpreter, to use join
>> do join to-path do my-path 'a-further-refinement
; is terrific and has led me to
my-path:  to-path join reduce[ my-path ] 'a-deeper-tag
Nope 
another typo
  my-path: t2/f
That is trivial
It has to be 
  my-path: 't2/f
or
  my-path: to-path [t2 f]
Gabriele
13-Sep-2007
[897x3]
JOIN does a reduce, so that's probably your problem. to-path reduce 
is not doing what you expect there, it's creating a path inside a 
path (no wonder it may crash :).
use append copy path word
also, you need to reduce your blocks above, because you have words 
in them, not subblocks.
RobertS
13-Sep-2007
[900x6]
Thanks.  I should also have used a type block in my func 

   augpath: func [ {augment a path with a word} path [path!] functor 
   [ word! ] /local p ] [
Once there are only subblocks it becomes trivial;  I have been trying 
to augment a path! series which starts with a block in which a tagged-word 
is bound to a block .  By augment the path I mean to return a path, 
not the result of evaluating the path
  t1: [ a-word-with-no-value-functor "one" ]

  t2: [ functor t1 ]  ; t1 is a word, not a block, but is bound to 
  a block at the time the path is extended into it ( if possible without 
  t2 being an object! )
  t2: context [ functor t1] ; also trivial
; this work fine for traversal
>> navpath: func [ pth [path!] 'wrd [word!] /local p42 ] [
[    p42: do pth
[    to-path reduce [p42 :wrd]]
>> pp: navpath path a
== t1/a
>> do pp
== "one"
where path was
path: to-path [ t2 f ]
>> t1
== [a "one"]
>> t2: context [f: t1]
>> t2/f
== [a "one"]
>> t2/f/a
== "one"
>> first t1
== a
>> get first t1
** Script Error: a has no value
** Where: halt-view
** Near: get first t1
>> get first third t2
== [a "one"]
>> do append copy 't2/f 'a
== "one"
Gabriele
13-Sep-2007
[906]
if you want to have words instead of the actual blocks in your blocks, 
then you need to "evaluate" the path yourself, which is not too hard.