Comment by tmtvl
9 days ago
In Common Lisp:
(defparameter *test-array*
(make-array '(10 5)
:element-type 'Float
:initial-element 0.0))
(typep *test-array* '(Array Float (10 5)))
And the type check will return true.
Compile-time checks is what's implied in virtually all these conversations.
Does that check run at compile time?
If I define a function foo which takes an (Array Float (10 5)) and then define a function bar which uses the result of calling foo with an (Array String (3 3)) then SBCL will print a warning. If I don't redefine foo and call bar with such an array then a condition will be raised. It's not quite the same as, say Rust's 'thing just won't compile', but that's due to the interactive nature of Common Lisp (I believe someone called it the difference between a living language and a dead language (though the conventional meaning of living language and dead language in programming is a bit different)).
Can you replace 10 5 and 3 3 with variable names and still get the warning without first calling the function?
2 replies →