World: r3wp
[Core] Discuss core issues
older newer | first last |
Ladislav 15-Sep-2006 [5337] | ...the problem with deci! could be address in the same way that plt-scheme does... - there is no problem with deci!, it is decimal! that has got a problem |
JaimeVargas 16-Sep-2006 [5338] | Ah. Well then apply my comments to decimal! |
Ladislav 18-Sep-2006 [5339x4] | do you like this: any [1 true] ; == 1 ? |
sorry, bad cut and paste, forget about it | |
what would you prefer this expression to return, 1 or 2?: loop 1 [ f: func [x] [ either x = 1 [ loop 1 [f 2] 2 ] [break/return 1] ] f 1 ] | |
I take "either is fine" as a possible answer too | |
Rebolek 18-Sep-2006 [5343] | I prefer "2". |
Ladislav 18-Sep-2006 [5344] | sorry, I should have posted my question to Rebol3 group, probably, because it is about the new behaviour mainly |
Volker 18-Sep-2006 [5345x3] | 2 too. the result of "f 2" is thrown away, the last value 2. should be returned. i would not expect some side-effect here. |
The break/return should only change that with a f: func[[throw] x] IMO. | |
Maybe without even give an error. | |
Anton 18-Sep-2006 [5348] | (continue in Rebol3 group) |
Graham 20-Sep-2006 [5349x3] | I think this is a bug ... |
to-local-file what-dir | |
it removes the trailing "/" | |
Anton 20-Sep-2006 [5352] | Yep, the DOS/Windows way of representing directories is buggy. Rebol is not at fault here. |
Henrik 21-Sep-2006 [5353x2] | what's the easiest equivalent to: >> set to-path [a b c] 7 ; doesn't work |
where the block may be a set of arbitrary words in an arbitrary object. | |
Rebolek 21-Sep-2006 [5355x2] | Certainly not the most elegant sollution: set-path: func [pth val /local rslt][ rslt: copy [] head insert/dup head rslt [in get] -1 + length? pth repeat i length? pth [append rslt to block! form to path! reduce ['pth i]] set do bind rslt 'pth val ] |
>> a: context [b: context [c: 0]] >> a/b/c == 0 >> set-path [a b c] 7 == 7 >> a/b/c == 7 | |
Henrik 21-Sep-2006 [5357x2] | wow, that's a lot of stuff alright... |
well, it seems to work, thanks :-) | |
Ladislav 21-Sep-2006 [5359] | do reduce [to set-path! [a b c] 7] |
Rebolek 21-Sep-2006 [5360] | hehe I knew there's some simple way :) |
Henrik 21-Sep-2006 [5361] | ladislav, I did that one, but somehow I have trouble binding the result to the original object |
Ladislav 21-Sep-2006 [5362] | yes, the word 'a must have proper context for this to work |
Henrik 21-Sep-2006 [5363x2] | do reduce bind [to set-path! [a b c] 7] 'a does not seem to work |
rebolek: it doesn't handle paths with indexes in them. I don't always store objects inside objects, but also blocks of objects. are there ways around that? | |
Ladislav 21-Sep-2006 [5365x3] | do reduce bind [to set-path! [a b c] 7] 'a does not seem to work - right, that is not supposed to do anything meaningful, it simply keeps the context the word 'a had |
>> a: context [b: context [c: 0]] >> do reduce [to set-path! [a b c] 7] == 7 >> a/b/c == 7 | |
If 'a does not have meaningful context, then bind [...] 'a cannot repair the situation | |
Henrik 21-Sep-2006 [5368x2] | but 'a does have a meaningful context. I'll have to try a different approach. |
load mold reduce [to set-path! ... ] seemed to work | |
Anton 21-Sep-2006 [5370] | You shouldn't have to do that (load mold). Can we see a bit more of your code ? |
Henrik 21-Sep-2006 [5371x2] | rel-obj: make object! [] add-relation: func [path-block [block!] /local p v w] [ p: to-block 'rel-obj parse path-block [ any [ [set w word! ( unless all [ find either object? do to-path p [first do to-path p][[]] w insert tail p w ] [ do load mold reduce [to set-path! p make do to-path p reduce [to-set-word w none]] ] ] ] ] I'm not sure it's enough... |
it's only a small part of the function | |
Anton 21-Sep-2006 [5373x2] | usage example of add-relation ? |
eg.. add-relation [...] <-- what's in the block. And what's the result supposed to be ? | |
Henrik 21-Sep-2006 [5375] | I'm rewriting my relations engine, if you remember that one. I need to traverse rel-obj via paths, so I store the path as words in a block. This is in order to maintain the current position in a deep object. The input can be any arbitrary path of words and values. If the values or words don't exist, they will be created on the fly. That's what I use 'p for. |
Anton 21-Sep-2006 [5376] | Ah I see. |
Henrik 21-Sep-2006 [5377] | the code with the do load mold... is supposed to insert a new object at the path position if the current value at that point is 'none. I removed some of that "if none?" logic for clarity. |
Anton 21-Sep-2006 [5378] | So rel-obj can start out completely empty, but fill with values afterwards ? |
Henrik 21-Sep-2006 [5379x2] | yes. an example could be if rel-obj was empty: add-relation [users male "Joe"] add-relation [users female "Jenny"] later on, when you look it up, it's supposed to look like: get-relation [users] == [male female] get-relation [users male] == ["Joe"] You can go deep: add-relation [users male "Joe" age-group "Senior"] And you can do reverse relations: add-relation [age-group "Senior" users "Joe"] |
the rules and structure is completely arbitrary, which is one of the stronger points of the relations engine. however the current version forces you to use a path block structure of [word value word value word value...] which forces you to choose a value that will not be used for branches where only one path should exist. that's why I'm doing a rewrite. | |
Anton 21-Sep-2006 [5381] | I suspect you are assuming you can extend objects, which cannot be done in rebol currently. |
Henrik 21-Sep-2006 [5382x2] | the relations engine already does that :-) |
but I need some more freedom in the path block | |
Anton 21-Sep-2006 [5384x2] | No, I mean extending objects and keeping the same object. |
>> a: make object! [] >> b: make a [new: none] >> same? a b == false | |
Henrik 21-Sep-2006 [5386] | yes, but that problem was solved long ago. |
older newer | first last |