/ Published in: R
Expand |
Embed | Plain Text
Rebol [] Unprotect 'Class Class: func['Class Body [block!]][ Type: to-word Class unprotect Type set Type Make Object! Body Protect Type get Type ] Protect 'Class Unprotect 'new new: func[&Class [Object!] '&Param1 [word! block! unset!] '&Param2 [word! block! unset!] /local Param-Block ObjName class action ][ Param-Block: none ObjName: none Class: &Class if/else value? '&Param1 [ if (type? &Param1) = Word! [ ObjName: &Param1 ] if (type? &Param1) = Block! [ Param-Block: &Param1 ] ][ ] if/else value? '&Param2 [ if (type? &Param2) = block! [ Param-Block: &Param2 ] ][ ] Constructor: to-word pick pick Class 1 2 Obj: Make Class [] if/else not none? Param-Block [ params: copy "" foreach param Param-Block [ if string? param [ param: rejoin [{"} param {"}] ] append params param append params " " ] do temp: rejoin [{do get in Obj constructor} { } params] ][ ;do rejoin [ObjWord "/" constructor "/interactive" ] action: get in Obj 'interactive if/else (none? action) [ foreach p skip first obj 1 [ if not (function? get in obj to-word p) [ set in obj to-word p ask rejoin [to-string p ": "] ] ] ][ do action ] ] if/else not none? ObjName [ Set ObjName :Obj ][ Obj ] ] protect 'new unprotect 'extend extend: func['byRefObj [word!] Block [block!] /local Obj][ Obj: get byRefObj if/else (type? Obj) = Object! [ Unprotect byRefObj Set byRefObj Make Obj Block ][ print [byRefObj "is not an object." ] ] ] protect 'extend
You need to login to post a comment.
