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

[REBOL] Re: DyBASE test

From: knizhnik:garret:ru at: 28-Dec-2003 11:13

Hello SunandaDH, Sunday, December 28, 2003, 1:18:52 AM, you wrote: Sac> Konstantin:
>> And once object >> is created it is not possible to add fields to it (very strange >> restriction for such flexible and dynamic language as Rebol).
Sac> In simple cases (if the object is not yet referenced anywhere else), it is Sac> very simple.... Sac> an-object: make object! [field1: now] Sac> an-object: make an-object [field2: true] ;; "adds a field" Sac> Problems may arise if the original an-object is referenced elsewhere: Certainly it is referenced! The main idea of creation object before loading its fields is to be able to handle cyclic references. So when object is created, it is placed in hash table which maps OID (object identifier) to the object instance. So if during fetching object fields I find reference to the same OID, reference to it can be obtained from hash table and there is no idle recursion. Also please notice that there are not only direct self references (in this case I can use "self" word in initialization of correspondent field). But fetched fields can contain references to other objects which also has to be loaded and then indirectly reference original object. Certainly it is possible to do fetching of object in two steps - at first jusrt extract all fields data, store it in some temporary block. Then create object using this block. And after it resolve references by performing OID lookup. But it significantly complicates fetch procedure and also make it not possible to load object methods (because only data fields are stored in database). Sac> a-block: copy [] Sac> an-object: make object! [field1: now] Sac> append a-block an-object Sac> an-object: make an-object [field2: true] Sac> append a-block an-object Sac> probe a-block/1 ;; not the same as Sac> probe a-block/2 ;; this Sac> See also Sac> http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=extend-an-obje Sac> ct.r Sac> and its documentation -- it may be doing what you need (though it doesn't Sac> solve the existing-references problem) Sac> Sunanda. -- Best regards, Konstantin mailto:[knizhnik--garret--ru]