Search code examples
typesrebolrebol3

What's known about UTYPE! in REBOL 3?


The only information I can find on the datatype UTYPE! is "not yet been documented for R3" and "user defined datatype", still giving a shred of hope that I can break out of Rebol's canon of predefined datatypes and formulate the polymorphism of my functions in a more straightforward manner. Just... I've no idea how to deal with UTYPE!. Trying:

make utype! <2nd-arg>

with several kinds of arguments (including an object) was invariably leading to "Script error: invalid argument: <2nd-arg>".

So, how to operate with it? Is this feature implemented at all? And if not, is there anything known about how it is intended to work?

BTW, I'm well aware home brewed datatypes can be simulated by constructs like:

make object! [
    class: ...
    value: ...
]

Supplement, written on November 8:

Playing with UTYPE! effects HELP:

>> foo!: make utype! [[] [random: func [value] [42]]]
>> type? foo!
== utype!

>> ? echo
USAGE:
    ECHO target

DESCRIPTION:
    Copies console output to a file.
    ECHO is a native value.

ARGUMENTS:
REBOL System Error:
REBOL System Error #1224: assertion failed

Program terminated abnormally.
This should never happen.
Please contact www.REBOL.com with details.

(2.101.0.2.5 on Lion). There was certainly something going on under the hood.


Solution

  • If you view the Rebol source code on github (https://github.com/rebol/rebol/blob/25033f897b2bd466068d7663563cd3ff64740b94/src/core/t-utype.c) it is clear that this feature has not been built yet.

    Comment from the header of the file:

    **  Notes:   NOT IMPLEMENTED
    

    Searching through curecode.org brings back a number of comments which show the direction that is planned for the utype! datatype.

    There's a plan to add user-defined datatypes - we even have a built-in type reserved for this, utype!. This would allow us to add new datatypes which respond to the actions, which would allow us to even have them support math operations if necessary. The only thing you wouldn't get is custom (non-construction) syntax for the type, or the ability to fit in a value slot. - BrianH

    Source: http://curecode.org/rebol3/ticket.rsp?id=2137