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

[REBOL] Re: comments for beginner ugly code ;-)

From: lmecir:mbox:vol:cz at: 18-Mar-2005 9:31

[sags--apollo--lv] napsal(a):
>O'k! >I am unshure how in this case the works 'err! >Is the refinement /local err is for generating error messages? > >brgds >Janeks >
/local is a refinement signaling that the variables following it are local variables. That means, that 'err is a local variable used to store intermediate result. Below is a more "polished" Default version. The Fault block may use Error variable "knowing" the error value. default: func [ {Execute code. If error occurs, execute fault.} [throw] code [block!] {Code to execute} fault [block!] {Error handling code} ] [ either error? set/any 'code try code [ fault: make function! [[throw] error [error!]] fault fault code ] [get/any 'code] ] Examples:
>> default [join "apples" "pears"]["no good"]
== "applespears"
>> default [join "apples" "pears" / 0]["no good"]
== "no good"
>> default [join "apples" "pears" / 0][print mold disarm error]
make object! [ code: 312 type: 'script id: 'cannot-use arg1: 'divide arg2: 'string! arg3: none near: [join "apples" "pears" / 0] where: 'default ] -Ladislav