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

[REBOL] Re: A question of function interface design

From: carl::cybercraft::co::nz at: 23-Jan-2005 18:38

On Wednesday, 19-January-2005 at 19:17:54 Peter wrote,
>I have started to question whether it is best to use Rebol's automatic type >checking of parameters or not when designing functions.
One reason not given so far for using it is that it makes it easy to see what types a function will accept. Compare READ and LOAD for instance...
>> ? read
USAGE: READ source /binary /string /direct /no-wait /lines /part size /with end-of-line /mode args /custom params /skip length DESCRIPTION: Reads from a file, url, or port-spec (block or object). READ is a native value. ARGUMENTS: source -- (Type: file url object block)
>> ? load
USAGE: LOAD source /header /next /library /markup /all DESCRIPTION: Loads a file, URL, or string. Binds words to global context. LOAD is a native value. ARGUMENTS: source -- (Type: file url string any-block binary) READ's description gets it right about what types are accepted, but LOAD's doesn't. Without them in the arguments, we'd have to view (and understand) the source to be sure what can and can't be accepted - and probably need to enclose the function in an error-trap anyway, just to be on the safe side. Long term, you'll probably find this will apply to your own functions as well. -- Carl Read.