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

[REBOL] context of a function Re:(2)

From: agem:crosswinds at: 19-Aug-2000 21:09

hey, thats tips! funally i can dump my functions after error! Thanks, Elan! .. ugly addings by me :) [REBOL [ title: "a func with dumpable context :)" author: "Elan, Volker" purpose: { [dump-func a-func] will source & dump locals, if defined with debug-func (alias Elan's cfunc). you can set func: :debug-func because there is a original-func set too. } version: file: %/home/volker/w/rebol/dump-func.r date: 19-Aug-2000/13:32:44+1:00 ] if not value? 'original-func [original-func: :func] dump-func: func ['f1] [ do compose [source (f1)] f1: get f1 locals: copy first :f1 bind locals first second :f1 ? locals forall locals [if word? first locals [ probe first locals probe get first locals]] ] [ ;Elan, bit modified ] debug-func: func [spec body /local found] [ either found? found: find/tail spec /local [ insert found [function-self] ][ insert tail spec [/local function-self] ] insert body [function-self] make function! spec body ] print "---" f1: debug-func [a b] [] f1 "the a" "the b" dump-func f1 f2: debug-func [/local a /opt b] [a: "in f2"] f2 dump-func f2 [; or use func allways, but func: :debug-func func: :original-func ] ()] --- [rebol--techscribe--com] wrote on 18-Aug-2000/12:55:03-7:00