Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: DyBASE test

From: moliad:aei:ca at: 30-Dec-2003 0:17

did you know you didn't have to use actual objects to implement object-like behaviour. this has the effect that you can extend the "object" at will... just use a block with set-word values. I have no ideas about speed, just that this could be a solution to your problem example:
>> object: [
id none name none ]
>> object/name: "gary"
== [ id none name "gary" ] == print object/name gary add a new item to object:
>> append object reduce ['field "chester the cat"]
== [ id none name "gary" field "chester the cat" ]
>> print object/field
chester the cat Some gurus on this list might might correct me, but in the context of your problem, this sounds like a fix to your problem. You can also put functions in such a block and use it, BUT remember that self word is not set by default, you would have to add it to the function's arguments (like in python) and supply the block, to which the function is part of... like this: object: compose [ id none name "gary" field "chester the cat" status ( func [self][ probe length? self foreach [item data] self [ either (function! <> type? :data) [ print [item "=" data] ][ print [item "()"] ] ] ]) ] object/id: 1234 object/status object 8 id = 1234 name = gary field = chester the cat status () HTH!!! -MAx