3 ms·
> * The relation between the various native data-types were quite unclear to me. http://sellout.github.io/media/CL-type-hierarchy.png http://sellout.github.io/
by phoe-krk 10y ago
> * The relation between the various native data-types were quite unclear to me.
http://sellout.github.io/media/CL-type-hierarchy.png http://sellout.github.io/media/CL-type-hierarchy.png
- znpy 10y ago> http://sellout.github.io/media/CL-type-hierarchy.png http://sellout.github.io/media/CL-type-hierarchy.png Indeed. Take for example base-char, which is a type. base-char derives (derives? the straight solid black line is not represented in the legend) from character, which is a built-in class (according to legend). So is character a class too? does base-char encapsulate a character or something like it? Before anyone comment, please keep in mind that this comment doesn't want to start a flame or be critical in any way.
- lispm 10y agohttps://pbs.twimg.com/media/C56V5kyWMAAi0DD.jpg https://pbs.twimg.com/media/C56V5kyWMAAi0DD.jpg Blue are CLOS classes. Brown are structure classes. Red are built-in classes. Black are types without any classes. This is the hierarchy for types in LispWorks, packages CLOS and CL.
- db48x 10y agoTypes in Common Lisp may or may not be represented by classes (all classes are types, not all types are classes). In this case, character is indeed a class, while base-char is not. It's definitely true to say that base-char is a subtype of character, in that some characters are also base-chars, while others are not. (The spec defines that there are at least 96 standard characters, all of which are of type standard-char, and thus also of type base-char. Implementations may add others. Interestingly, the spec doesn't define how those characters are encoded; of course most modern implementations use some variant of Unicode.) Some examples: (typep #\A 'base-char) ⇒ true (typep #\A 'standard-char) ⇒ true (typep #\A 'extended-char) ⇒ false (typep #\A 'character) ⇒ true (typep #\𝀽 'base-char) ⇒ false (typep #\𝀽 'extended-char) ⇒ true etc.