|
Users can create new types (instances of <type>) that are by default
uninstantiable (singletons, limited types, union types) and can then
define make methods for them, making them instantiable, although
I'm not sure that should fall into recommended practice.
Users can't create new kinds of types; that is, users cannot create
new subtypes of <type> in the portable language.
Well, I suppose I can define a new instantiable type like so:
define $days = #[
#"sunday", #"monday", #"tuesday",
#"wednesday", #"thursday", #"friday",
#"saturday" ];
define constant <day> :: <type> =
reduce1(union, map(singleton, $days));
define method make
(type == <day>, #key ordinal, #all-keys)
$days[ordinal]
end method make;
but I'm not recommending that.
> Or, rather, is there something here that implementations can do
> but users can't?
Yes. Making new direct subclasses of <type>. For example, Dylan
defines union types, but not intersection types. There is no portable
way I know of to portably create an intersection type which can be
used as a method specializer.
|