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

[REBOL] Re: RFC on support for user-defined "types"

From: lmecir:mbox:vol:cz at: 11-Jun-2002 22:01

Hi Joel and Gregg, Gregg's suggestion is absolutely straightforward, that is what prototypes are for. My contribution is a function, that checks this: compatible?: func [ prototype [object!] object [object!] ] [ empty? exclude first prototype first object ] Cheers -L ----- Original Message ----- From: "Gregg Irwin" Hi Joel, << In other words, we'd be specifying (a portion of) the *interface* that an object should possess, rather than a (non-REBOL) notion of "class". This would allow the above hypothetical function definition to be written as: somefunc: func [ a [object! [invert]] b [object! [memorize]] ... ][ ...blah blah blah... ... a/invert ... ... b/memorize ... ] to document/enforce that the first argument must possess an INVERT attribute/method and the second must have a MEMORIZE attribute/method, with the checking to be done by the interpreter at the/each point of function invocation (e.g., as type checking is done now).
What about specifying a prototype object instead of a block of words for an anonymous object? I'm thinking that the list of words could get quite long and perhaps be used in many places which might become burdensome. Just my 2% of $1.00 :) --Gregg