4 ms·
Common Lisp is not untyped. It is dynamically typed. Common Lisp is also object-oriented with classes, generic functions and methods. CL-USER 6 > (defclas
by lispm 4y ago
Common Lisp is not untyped. It is dynamically typed.
Common Lisp is also object-oriented with classes, generic functions and methods.
CL-USER 6 > (defclass foo ()
((bar :type number :initform 0)))
#<STANDARD-CLASS FOO 82200CF0DB>
CL-USER 7 > (defmethod add-number ((object foo) (n number))
(incf (slot-value object 'bar) n))
#<STANDARD-METHOD ADD-NUMBER NIL (FOO NUMBER) 80100E116B>
CL-USER 8 > (let ((foo1 (make-instance 'foo)))
(add-number foo1 10)
foo1)
#<FOO 80100E185B>
CL-USER 9 > (describe *)
#<FOO 80100E185B> is a FOO
BAR 10
Thus the source code will contain lots of class definitions, lots of methods with multiple argument dispatching over classes.
Thus the source code will contain all the usual class and method declarations.
Common Lisp may also contain optional type declarations. For above example the slot BAR of the class FOO has a type NUMBER.
- dgan 4y agoalright, taking my stone back to my yard! I didn't know CL was typed