Seeing as you can limit the parameters of functions to specific datatypes, it stands to reason that you might want to define your own datatype, yet I cannot see anything in the Rebol docs that suggests this as a feature of the language (unless I didn't look very well).
What I am expecting is the ability to do something like the following:
mytype!: make datatype! ... ; some spec here
Is this possible? The following does not fill me with much hope:
http://www.rebol.it/giesse/custom-types.r
From the link:
Purpose: { Allows the programmer to define custom REBOL datatypes }
It is a rather lengthy piece of code. Not what I was hoping for.
Tried an implementation of utypes in https://github.com/giuliolunati/rebol/tree/utype
As an example, I implemented complex! utype
Basically, utypes are implemented as objects with special methods in dotted form: so, .add implements the + op etc.
For now you can overload all actions (but make), and some natives (math functions, comparison, form, mold, print, probe)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With