On Friday 23 January 2009, =DEemseddin Moldibi [ Bircom ] wrote:
> Hi, is it possible to force a function get a parameter which is a =3D
> user-defined object type? I guess no, but I would like to be sure. =3D
> (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" =3D foo/_class_name_=20
][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" =3D foo/_class_name_=20
][do-something][throw-error]
:-)Beware: untested code!
HTH
tim
--
To unsubscribe from the list, just send an email to
lists at rebol.com with unsubscribe as the subject.