Re:Lisp and Haskell (2017)
by waterhouse on Saturday July 14, 2018 @11:49PM
(#17533697)
For what it's worth, on a fairly recent SBCL, here's what the compiler/interpreter prints when you enter the author's function:
Thus, it identifies the exact problem the author describes at the end.
[ Parent
| on HN ]
Re:Lisp and Haskell (2017)
by fiddlerwoaroof on Sunday July 15, 2018 @12:52AM
(#17533856)
Yeah, just because the language doesn’t force you to specify types, doesn’t mean that the compiler can’t infer them for you.
What was most eye-opening for me about CL was just how helpful the compiler of a dynamically typed programming language can be.
Checking dynamic types us not the work of a compiler. Checking types at compile time is static type checking. If a type is wholly dynamic (determined at runtime via something like casting to a type specified in user input), the compiler can't check it.
(Also, type inference is orthogonal to static vs dynamic typing.)
> Checking dynamic types us not the work of a compiler. Checking types at compile time is static type checking.
By your logic, Common Lisp is both dynamically and statically typed, because compile-time type checks are done by the compiler and warnings/errors are signaled whenever proper.
More, if you declare (OPTIMIZE SPEED), the compiler is going to print a list of all places where it was unable to infer types on its own and where it expects help from the programmer in form of type declarations for individual variables.
Also: why would padding be an optional keyword parameter (defaulting to nil!) when it's required to be a non-negative integer for the function to work correctly?
Since it is required, it wants to be a required parameter.