[REBOL] Re: Object "names" ?
From: carl:cybercraft at: 29-May-2009 19:03
Hi Kai,
Taking a guess at what you might be doing with this, an approach like this might be better...
template: make object! [ count: 0 ]
objs: []
append objs reduce [ 'a make template [] ]
append objs reduce [ 'b make template [] ]
append objs reduce [ 'c make template [] ]
That creates a block of word/object pairs which can then be accessed like this...
>> objs/a/count
== 0
>> objs/b/count
== 0
>> objs/b/count: 2
== 2
>> objs/b/count
== 2
>> objs/a/count
== 0
It sounds like you're creating some kind of database, and there's a limit to the number
of words that REBOL can handle when they reference a value. (Others can rephrase that
more correctly...) There's no limit to the number of words that can be stored in a block
though. And being in a block, you'd be able to sort them by name as well, if required.
ie...
>> foreach [word object] objs [print word]
a
b
c
>> sort/reverse/skip objs 2
== [c make object! [
count: 0
] b make object! [
count: 2
] a make object! [
count: 0
]]
>> foreach [word object] objs [print word]
c
b
a
Oh, and the reason your...
probe first find objs a
seemed to work is it was looking in objs for the object referenced by 'a and not for
the word 'a. ie, this would fail...
probe first find objs 'a
Hope that helps.
-- Carl Read.
On Thursday, 28-May-2009 at 18:22:48 Kai Peters wrote,