Strong Typing (Re: Managing metadata about attribute types) <Pine.LNX.4.44.0311171402340.1133-10

I don’t advocate type checking much in either case. It is a performance
killer. I would rather have all my data/objects pre-qualified already
at admittance into the system and just assume that all are correct
and able to behave themselves. However, at the qualification points,
some good checking capability is needed - and IMHO both methods are
needed presently.

the programming language euphoria has an interesting approach to this. in euphoria you have only four real types, but you can create user defined types which are nothing more than methods the return true or false if the varaible meets the requirements of the type. so you might do something like this pusedo-ruby example:

type silly(x)
(x === Array and x.include?(‘silly’))
end

silly :variable

at the appropritate points in execution the variable is ensured to meet the type requirement or an error is thrown. (of course one would have to figure out how to apply this to the different types of variables in ruby --local, instance, etc.)

but what’s cool about it is that you can turn all type checking off either on the command line or by a special “kernel” method in your program. so this gives you three options. if you really need strong typing, i don’t think you can get much stronger, but at the cost to execution speed. or you can use it just for testing purposes --when everything looks good you can turn it off to get a speed boost. or you don’t have to use it at all. the only downside is that it doesn’t improve execution speed at all, as typing does for static languages. but hey, that’s the price you pay for the ease of a dynamic language.

by the way, i was very surprised by the number of features euphoria has that are akin to ruby. although euphoria is bit toyish, from what i can tell. in many ways it seems like euphoria is to ruby as logo is to lisp. i wonder if matz new about euphoria when we created ruby? (i think it’s slightly older than ruby). it also has other interesting features, you might want to take a look:

http://www.rapideuphoria.com/refman_2.htm#43 (type system)
http://www.rapideuphoria.com/refman.htm (documentation)
http://www.rapideuphoria.com (home page)

-t0