words&context was: (Re: Update)
[1/4] from: cyphre:volny:cz at: 25-May-2001 10:46
Hi Ladislav and all,
Your docs are very interesting. Since I haven't study them detailed yet I
would like show you my problem regarding contexts because it seems you have
better experience in exploration of this field...
I'm still trying to find a solution for adding/setting a new word to context
without using 'make and here are some of my findings:
>> a: make object! [b: 5]
>> probe a/self
make object! [
b: 5
]
>> a/self: make a/self [b: 8 c: 10]
>> a/c
** Script Error: Invalid path value: c
** Near: a/c
>> a/b
== 5
>> a/self/b
== 8
>> a/self/c
== 10
>> probe a/self
make object! [
b: 8
c: 10
]
>> probe a
make object! [
b: 5
]
>>
seems like 'self doesnot work dynamically...bug or feature?
In this example you can see how is crating of new words in specified context
agressive. I hope we will need another method for adding new words. Without
this is not possible to make modular software...
Here is example for better explanation:
ModuleA: make object! [...]
ModuleB: make object! [...]
main-script: make object! [
....blablabla...
]
How can I insert modules A and/or B into main-script(I really don't need
them in global context)??
another example of using creatinon new words in specified context is even
more difficult:
in this example I want to display on screen different faces for example
including some tables...I also need to add new table to screen.
screen: make face [
table1: make face [...]
table2: make face [...]
pane: [table1 table2]
]
view l: layout [
bx: box with [pane: sceeen]
button "add table3" [
screen: make screen [
table3: make face [...]
]
append screen/pane in screen 'table3
show l
]
]
This method doesnot work because of agressive using of 'make when adding
word table3 while is face screen viewed.
Maybe you could ask why I want to use this method?
I want to choose this method because of easier access into tableX faces for
example:
screen/table2/color: blue
to get all names of subfaces I just use
all-table-names: copy screen/pane
etc.
Normally is used method where pane is a block of faces, not words reffering
to faces in specified context, like:
screen: make face [
pane: [make face [...] make face [...]]
]
in this situation I can use just
screen/pane/1 or screen/pane/2 etc.
I this case I also have to know exact position in pane and need to identify
panes somehow to work with them like:
screen: make face [
pane: ['table1 make face [...] 'table2 make face [...]]
]
this is better solution but again the acces to subfaces(tables) is more
complicated than in method of using pane: [block of words]
I you are understood my confused text and have any comments or solution
don't hesitate to write it ;-)
regards
Cyphre
[2/4] from: lmecir:mbox:vol:cz at: 29-May-2001 17:58
Hi Cyphre,
there is no way how to "extend" an existing object currently. You can only
simulate such behaviour, i.e. write a work-around. If you think I can help
you, try to send me (possibly personally - you can use Czech language) some
code you are trying to write. I am not sure I understood the meaning of your
examples.
Ladislav
[3/4] from: lmecir:mbox:vol:cz at: 30-May-2001 18:26
Hi,
I just corrected http://www.sweb.cz/LMecir/contexts.html
It contained an alias bug.
Regards
Ladislav
[4/4] from: robert:muench:robertmuench at: 4-Jun-2001 11:45
> -----Original Message-----
> From: [rebol-bounce--rebol--com] [mailto:[rebol-bounce--rebol--com]]On Behalf Of
<<quoted lines omitted: 4>>
> there is no way how to "extend" an existing object currently. You can only
> simulate such behaviour, i.e. write a work-around.
Hi, don't know if it's still a topic for you but here is a "workaround", you are
right that there is no native way to extend an object.
extend-object: func ['obj-word [word!] 'word [word!] value [any-type!] /local
the-obj][
all [not object? the-obj: get obj-word make error! "No object provided."]
if in the-obj word [
set in the-obj word value
return the-obj
]
set obj-word make the-obj reduce [to-set-word word value]
]
use like:
extend-object objectoextend newword newvalue
Robert
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted