2 ms·
> (let ((c (make-instance 'circle :center '(0 0) :radius 4))) ... Erm, what? This is supposed to show smart compile-time checking about runtime behavior?? Th
by gwern 17y ago
> (let ((c (make-instance 'circle :center '(0 0) :radius 4)))
...
Erm, what? This is supposed to show smart compile-time checking about runtime behavior?? This no more demonstrates what you apparently think it demonstrates than I could demonstrate Haskell's type-soundness by taking some Template Haskell, inserting 'head []', and saying 'it crashes during compilation, eureka!'
What would be fairer would be wrapping all that in a '(defun foo () )', in which case one doesn't get any warning relating to the 'location c' or "B":
* (load "foo.cl")
STYLE-WARNING: Implicitly creating new generic function CIRCLE-AREA.
; in: LAMBDA NIL
; ((LET ((C (MAKE-INSTANCE 'CIRCLE :CENTER '# :RADIUS 4)))
; (FORMAT T "~A~%" (CIRCLE-AREA C))
; (SETF (CIRCLE-CENTER C) '(2 3))
; (SETF (CIRCLE-RADIUS C) 7)
; (SETF (CIRCLE-RADIUS C) "B")
; (LOCATION C)))
;
; caught ERROR:
; illegal function call
;
; compilation unit finished
; caught 1 ERROR condition
T
- deleted 17y ago[deleted]
- jgrant27 17y agoIt's runtime checking. I really don't care though. Common Lisp just has a different approach, it sits between static typing and dynamic typing. It's type declarations are for optimization. Which I see as the main benefit anyway. Besides, I've been around long enough to have seen applications that were implemented using statically-typed languages, simply explode. Static typing, IMHO, is extremely overrated. Since many statically typed languages make it easy to cast one type into another, you can't trust it to be anything more than an optimization hint. This been quite the diversion(thanks). I'm mainly interested in meta-programming in Haskell & how it compares with Lisp.