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

[REBOL] A question of function interface design

From: pwawood:mango:my at: 19-Jan-2005 19:17

I have started to question whether it is best to use Rebol's automatic type checking of parameters or not when designing functions. If the type checking is used, calling a function with an incorrect type of value causes a script error, eg:
>> a: func [b [date!]] [print b] >> a 12345
** Script Error: a expected b argument of type: date ** Near: a 12345 However, if you don't use the built-in type checking, you can return a none! value and give the caller the option (and responsibility) to deal with the situation, eg:
>> a: func [b] [if type? b <> date! [return none]] >> a 12345
== none Given that Rebol is not strongly typed, is the second of these "idioms" the more appropriate? Regards Peter