|
Home
>
3. concept
>
3.3 types and classes
>
3.3.1 types
>
3.3.1.1 some types are not classes in Dylan
|
Previous
Next
|
|
|
|
|
|
|
Type is a more general notion than class in Dylan. In fact some
types are not classes in Dylan.
|
|
Eric Dujardin
|
Singleton types seem not to be classes, do they ?
Does the difference also involve the limited and union types that you
mention below?
Are there any other types that are not classes ?
|
|
Steve Strassmann
|
All singletons are instances of <singleton>. Singletons, and instances
of <singleton> are the same things.
There's a big difference between singleton(3) and the number 3. The
former is an instance of <singleton>, the latter is an instance of
<integer>.
There's a big difference between singleton(3) and the class
<singleton>. The former is an instance of the latter.
A singleton is a type, not a class. You cannot call 'make' on types
which are not classes. You cannot call make(singleton(3)), but you
can call instance?(3, singleton(3)), which returns true.
<Singleton> is an ordinary class, and it's a subclass of <type>. You
can call make(<singleton>, object: 3) and get back the same thing as
calling singleton(3).
Page 84 of the DIRM has all the interesting type introspection
functions.
Note that any Dylan object can possibly belong to many types at
once, but it can only be the direct instance of exactly one class.
'object-class' will always return some class no matter what its
argument is.
|
|
Paul Haahr
|
> You cannot call 'make' on types which are not classes.
Excepting, of course, limited collection types. (Design note 6.)
The rule specified in the DIRM is that make may be called on
``instantiable types,'' of which there are two defined by the language:
classes and limited collections. (The latter may be implemented as
classes, according to the design note.)
Note, by the way, that not all classes are instantiable types. Abstract
classes are by default not instantiable. And, by defining a make
method I can switch the classification for a particular type.
|
|
|
|
|
|
|
|
|