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

[REBOL] Re: Object Sea - Work in Progress

From: rotenca:telvia:it at: 21-Feb-2002 18:02

Hi, Andrew This is your file with my corrections. I checked only the error problem, not the work of function. There was 2 problems: you executed the functions inside objects instead of only referencing it. (I ask myself why it crashed Rebol, instead of only throwing an error.) In general there are other problems with load/save: 1) a file like % which comes from a: context [b: tail %local/any.r] can't be restored by load (which gives an error - perhaps other series have the same problem). 2) series must be saved from head and then re-positioned, if we want to clone the object. 3) unset value can not be restored (should be called the unset func on every unset value) 4) i think there is something else but i did not remember what... Ciao Romano ------------------- Rebol [ Name: 'Sea Title: "Sea" File: %Sea.r Author: "Andrew Martin" eMail: [Al--Bri--xtra--co--nz] Date: 21/Feb/2002 ] Outrider: make object! [ N: "Antidisestablishmentarianism" ] ; Example object sea. Sea: reduce [ make object! [ M: 123 Name: "Sea #1" O: none F: func [X [integer!]] [M: M + X] ] make object! [ M: 456 Name: "Sea #2" O: none F: none ] make object! [ outside: Outrider ] ] ; First and second objects contain each other. Sea/1/O: Sea/2 Sea/2/O: Sea/1 Sea/2/F: get in Sea/1 'F Freeze: function ["Freezes Object Sea" Sea [block!] /Compact] [Path Index] [ foreach Object Sea [ foreach Word next first Object [ any [ if function? get in Object :Word [ true ] if object? Path: Object/:Word [ set in Object Word make lit-path! reduce [ '. either found? Index: find Sea Path [ index? Index ] [ append Sea Path length? Sea ] ] ] ] ] ] Sea ; At this point, the 'Sea has become ice. :) ] Melt: function ["Melts Object Ice" Ice [block!]] [Path] [ foreach Object Sea [ foreach word next first Object [ Path: to path reduce ['Object :Word] if all [ path? :Path 2 = length? :Path '. = first :Path integer? last :Path ] [ set in Object Word pick Ice last :Path ] ] ] Ice ; At this point, the 'Ice has become sea. :) ] probe Melt probe Freeze Sea halt