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

[REBOL] Re: User-defined function parameters

From: tim-johnsons::web::com at: 23-Jan-2009 11:10

On Friday 23 January 2009, =DEemseddin Moldibi [ Bircom ] wrote:
> Hi, is it possible to force a function get a parameter which is a > user-defined object type? I guess no, but I would like to be sure. > (sorry for bad english) > Look at example below please, > > My-Object: [name: "" age: 0] > F: func [a [My-Object!]] [...]
This is kind of a 'rigged' solution .... but it works for me. In python, rebol, and newlisp, I've adapted a strategy for objects or contexts: a member, always of the same name. In rebol, it might be _class_name_ so a check on the user type might be something like this. either all[ object? foo "some-class-name" = foo/_class_name_ ][do-something][throw-error] or if one is not sure one has followed the convention without fail either all[ object? foo in foo '_class_name "some-class-name" = foo/_class_name_ ][do-something][throw-error] :-)Beware: untested code! HTH tim