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

[REBOL] Re: Contexts of contrived blocks

From: lmecir:mbox:vol:cz at: 9-May-2001 23:23

Joel, I can show you another "black magic code" from my http://www.sweb.cz/LMecir/contexts.html f: func [level] [ make object! [ a: 2 * level b: either zero? level [ f 1 ] [none] a: a + 1 ] ] probe f 0 make object! [ a: 0 b: unset ] It can be repaired as follows: make-object: function [ { A non-modifying make object version, returns an object with any self value } [throw] blk [block!] "object spec" /proto prototype [object!] "object prototype" ] [result getres] [ getres: func [value] [result: :value] blk: compose [(:getres) :self (:blk)] error? make either proto [prototype] [object!] copy/deep blk result ] f: func [level] [ make-object [ a: 2 * level b: either zero? level [ f 1 ] [none] a: a + 1 ] ] probe f 0 make object! [ a: 1 b: make object! [ a: 3 b: none ] ] Regards Ladislav