3 ms·
A string in C is an implicit type; it's a specialization[1] of an array of characters. Another example of implicit type are Lists in Lisp (specialization of nes
by CodeArtisan 8y ago
A string in C is an implicit type; it's a specialization[1] of an array of characters. Another example of implicit type are Lists in Lisp (specialization of nested pairs).
[1] https://en.wikipedia.org/wiki/Specialization_(logic) https://en.wikipedia.org/wiki/Specialization_(logic)
- kazinator 8y agoA string in C is entirely built upon convention; it exists in the words of a document only. Common Lisp has a list class that you can specialize a CLOS method on. Also: [1]> (typep nil 'list) T [2]> (typep '(a) 'list) T [3]> (typep 3 'list) NIL And: [4]> (subtypep 'cons 'list) T ; T [5]> (subtypep 'null 'list) T ; T So, kind of apples and oranges.
- CodeArtisan 8y agoI was referring to John McCarthy's definition of a list. IIRC, Common lisp's list type includes both proper and unproper lists. (typep (cons 1 2) 'list) evaluates to true but (length (cons 1 2)) throws a type error (not a list).
- _kst_ 8y agoI guess you could think of it as an "implicit type". I prefer to think of it as a data format rather than a data type. (It doesn't satisfy the meaning of "type" as C defines the word.) char[n] (for constant n) is an array type. An object of type char[n] may or may not contain a string.