World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
RobertS 12-Sep-2007 [824x7] | ; I only have the issue if I build t2 to hold some functor and a word bound to a block rather than the block, i.e., not >> t1: [a "one" b "two" c "three" x [f "for"]] == [a "one" b "two" c "three" x [f "for"]] >> t2: reduce['functor t1] == [functor [a "one" b "two" c "three" x [f "for"]]] >> t2/functor/c == "three" |
t2/functor/x/f ; also OK of course | |
; this issue persists >> t2: [functor t1] == [functor t1] >> p3: to-path reduce[ t2/functor 'x] == t1/x >> do p3 == [f "for"] >> p3: to-path reduce[ t2/functor 'x/f] == t1/x/f >> do p3 ** Script Error: Invalid path value: x/f ** Where: halt-view ** Near: t1/x/f ; there seems to be no way to "append'" to a path ?? | |
>> p4: to-lit-path [t1 x/f] == 't1/x/f >> do p4 ** Script Error: Invalid path value: x/f ** Where: halt-view ** Near: t1/x/f >> t1/x/f == "for" | |
; this works >> p4: to-lit-path 't1/x/f == 't1/x/f >> do p4 == "for" ; but it is no help if t am trying to pass in the path the I wish to "extend" deeper | |
>> p4: to-path "t1/x/f" == t1/x/f >> do p4 ** Script Error: Invalid path value: t1/x/f ** Where: halt-view ** Near: t1/x/f >> type? p4 == path! >> get first p4 ** Script Error: get expected word argument of type: any-word object none ** Where: halt-view ** Near: get first p4 ; using get first or get second or get last usually is handy diagnosing what is reported as a path but in fact fails as a path | |
>> p4: to-path 't1/x/f == t1/x/f >> get first p4 == [a "one" b "two" c "three" x [f "for"]] | |
Chris 13-Sep-2007 [831x3] | ; If I'm understanding this correctly, you are trying to resolve a single path to a value in nested blocks (I'll take the liberty of reimaging the example): path: 'language/en/one language: [en english] english: [one "one" two "two"] resolve path ; == "one" |
; I'd look at this in two ways -- a) set up the blocks so the path works with 'do: language: reduce ['en english] resolve: :do resolve path ; == "one" | |
; or b) step through the path and resolve each value in turn: resolve: func [:path [path!] /local wd val][ wd: first path: copy path remove path val: get wd while [all [block? val not tail? path]] wd: first path remove path val: val/:wd if word? val [val: get val] ] val ] | |
RobertS 13-Sep-2007 [834] | I am trying to compare what I can do in Rebol to what I can do in another language with functors What hamstrings me is that a path cannot be extended unless the blocks are literally nested or in an object I am hoping some one will da ythat in R3 path! is more like a series! path: this/thing path: append path 'what rez: path |
Chris 13-Sep-2007 [835x2] | (sorry, missed an opening bracket in 'while) |
path: 'this/thing append path 'what probe path probe to-block path | |
RobertS 13-Sep-2007 [837x3] | sorry what is a bad choice make that 'whatever |
bind to two valid paths compose with one word nested in a block you can append all you want type? is path and the path will not be valid | |
my little pword func was the shortest thing I could build | |
Chris 13-Sep-2007 [840x2] | path: join 'language/en 'one probe resolve path path: join 'language/en 'two probe resolve path |
The path is not valid, so long as you are trying to resolve it with 'do. | |
RobertS 13-Sep-2007 [842x4] | why should that be so? |
the path is just word1/word2 and then is just word1/word/word3 Only word1 ever binds to a value | |
word1/word2/word3 ; guy can't even type ... | |
The path! that my 'pword func returns responds as expected to 'do | |
Chris 13-Sep-2007 [846] | Iin your example (again, if I understand correctly), 'do (or default behaviour) resolves each stage in the path. So, with a given path -- t2/f/b -- it'll go t2/f == 't1-- but this is just a word, not the value associated with the word. It's equivalent to this: val: 't1 val/b |
RobertS 13-Sep-2007 [847] | But is any valid deep path only the forst word has to have a value associated with it. e.g. block/tag1/tag2/tag3 |
Chris 13-Sep-2007 [848] | Only if you're evaluating with 'do. |
RobertS 13-Sep-2007 [849] | Even if I am doing result: constructedPath |
Chris 13-Sep-2007 [850] | That's sort of the same as evaluating with 'do. |
RobertS 13-Sep-2007 [851] | What should the behavior of 'join and 'append' and 'insert be when passed a path and a word? |
Chris 13-Sep-2007 [852] | What I'm getting at is there are limitations in the default handling of paths. But paths are series and you can evaluate them however you want to. |
RobertS 13-Sep-2007 [853x2] | Yes, get first path is a godsend |
Here is what Carl has said: Of course, not to discourage anyone, but we're going to be careful and choosy about what becomes part of R3. We've got our standards. We still value small, fast, and smart. REBOL is about getting great advantage and leverage from a well-designed tool, not about becoming yet another bloated and hard-to-manage computer language. | |
Chris 13-Sep-2007 [855] | join foo/bar 'ton -- will try and evaluate foo/bar then append 'ton join 'foo/bar 'ton -- will give you 'foo/bar/ton |
RobertS 13-Sep-2007 [856] | That is great but also of no help if a word is holding the path 'foo/bar I was hoping the solution was in to-lit-word |
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 [873] | join to-path do path 'a |
older newer | first last |