vindarel / lisp-journey

Discovering the Common Lisp ecosystem. https://lisp-journey.gitlab.io/
2 stars 0 forks source link

blog/compile-time-type-checking-in-common-lisp/ #30

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Compile Time Type Checking in Common Lisp - Lisp journey

We often hear that Common Lisp is dynamically typed, which is not wrong, but that leads to the belief that Lisp is as bad as Python concerning types, which is plainly wrong. We don’t hear enough that CL is a compiled language, that we can add type annotations, and that SBCL does thorough type checking. Hence, what we have at hand is awesome: we can compile a whole program or compile a single function and get type warnings.

https://lisp-journey.gitlab.io/blog/compile-time-type-checking-in-common-lisp/

vindarel commented 2 years ago

Hey, a thought on the CL/SBCL type system, especially if you come from Rust or Haskell:

I agree that relying on SBCL to compile-time type-check is probably a fool's errand. Don't get me wrong, it's incredibly nice that SBCL does this, and a huge productivity saver, but it's not entirely clear in practice what you're actually being guaranteed when your code does compile successfully. In that sense, I see it as more of "icing on the cake".

If you want deterministic, holistic compile-time type checking, while still getting to use Common Lisp, Coalton is an option. Feel free to join the Discord if you have questions.

Calling SBCL's static type checking "hacky" or "[up to] individual interpretation" is reflective neither of its implementation nor of its raison d'être (i.e., it's not there to compete with static type checking à la Rust or Haskell), and is ignorant of its innovative (in the context of Lisp) origin in CMUCL.

/u/stylewarning on /r/lisp