[REBOL] Re: About object!s and custom datatypes
From: gabriele:colellachiara at: 3-Jan-2005 12:04
Hi Hallvard,
On Sunday, January 2, 2005, 9:15:34 PM, you wrote:
HY> I tried to use custom-types.r to make my own datatype, but it didn't work,HY> because
some of Ladislavs subfunc-stuff crashed somehow. But here's a moreHY> theoretical question:
That's the downside of experimental code. ;) If you are using the
YourValues version (which is very different from my original
version), note that it is developed on the latest alphas.
HY> site1/equal? site2
HY> I would like to write
HY> equal? site1 site2
HY> like with basic datatypes like string!s and integer!s. The question is:HY> Would
this slow rebol down? What are the most important advantages andHY> disadvantages of
making one's own datatypes?
Replacing all the actions slows down REBOL noticeably. That's why
I don't do that anymore (only the first version of custom-types.r
did that). What I do is create new actions that can handle custom
types. I.e.:
equal?* site1 site2
The starred actions work on "normal" types too.
The disadvantage is that you might end up with more complications
than simplifications. :)
HY> I can think of this, for a start:
HY> I have, in the 'equal? func, refinements like /regard-section andHY> /regard-cgi-order.
I guess these cannot be brought into the 'equal? action?HY> Or is this not so?
You'd need a different "action". (The point of having "your own
datatype", IMHO, is that of following the standard interface of
all the other datatypes, so that you don't have to learn a new
API.) You could use EQUAL? and STRICT-EQUAL? but I guess that's
not enough for you.
This would need to be solved differently, design-wise...
HY> I find the idea of custom datatypes interesting. Please enlighten me on it'sHY>
(dis)advantages.
Sometimes having the same API for everything is a great advantage,
other times it's just a complication...
I guess this is not the answer you wanted to hear. :)
Regards,
Gabriele.
--
Gabriele Santilli <g.santilli-tiscalinet.it> -- REBOL Programmer
Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/