4 ms·
Since when CL is statically typed? LISP has only one type. The all mighty runtime type. It's a uni-typed language.
by still_grokking 4y ago
Since when CL is statically typed?
LISP has only one type. The all mighty runtime type. It's a uni-typed language.
- tmtvl 4y agoYeah, I'm sure deftype does nothing. (deftype option (subtype) "The type of a value that is either nil or a value of SUBTYPE." `(or null ,subtype)) (defun* get-latest-statement ((account account)) "If any statements have been made on the ACCOUNT, returns the latest. Otherwise returns nil." (:returns (option statement)) (car (last (account-statements account)))) I like defstar, it's a neat package.
- andsoitis 4y agoThe person you replied to didn’t say CL is statically typed. They said “powerful”. While CL (the standard) doesn’t require compile time type checking AFAIK, certain implementations, such as SBCL (probably the most popular non-commercial implementation), does offer compile time type checking. More on CL types, type checking, etc.: https://lispcookbook.github.io/cl-cookbook/type.html https://lispcookbook.github.io/cl-cookbook/type.html
- still_grokking 4y ago> They said “powerful”. Yes, it was called a "powerful type system". But a type system with only one type isn't powerful, more the contrary. https://existentialtype.wordpress.com/2011/03/19/dynamic-languages-are-static-languages/ https://existentialtype.wordpress.com/2011/03/19/dynamic-lan... But the now linked page was an interesting read. At least SBCL has indeed real types. I didn't know that until now. Compile-time type checking You may provide type information for variables, function arguments etc via `proclaim`, `declaim` and `declare`. However, similar to the `:type` slot introduced in CLOS section, the effects of type declarations are undefined in Lisp standard and are implementation specific. So there is no guarantee that the Lisp compiler will perform compile-time type checking. However, it is possible, and SBCL is an implementation that does thorough type checking.
- kazinator 4y agoCalling dynamically typed languages "one typed" is basically trolling; there is no substance behind it. Obviously, the expressions 1234, "foo" and '(hello world) do not have the same type.
- still_grokking 4y agoHave you read the linked post? Did you look up who the guy is who written it? Calling Mr. Harper a "troll" is quite a strong statement…
- lispm 4y agoCommon Lisp has more than one type. See the standard: http://www.lispworks.com/documentation/HyperSpec/Body/04_bc.htm http://www.lispworks.com/documentation/HyperSpec/Body/04_bc.... This exists since early 80s. The first language definition book appeared 1984: Common Lisp the Language. One could think that it is a gradual type system. Type declarations are optional and are used for several purposes. Many implementations use type declaration and optionally type inference as input for optimizing compilers. In the 80s the first implementation to add limited forms of static type inferencing and checking was CMUCL. SBCL is a later fork of CMUCL. The challenge is to integrate dynamic types, static types into a language which is often used interactively - including a lot of dynamic features, where programs can change at runtime or parts of the language might change during runtime. Thus the type system has its problems and hasn't been improved since the 90s... Not many implementations have adopted the type system implementation of CMUCL & SBCL. Generally the SBCL compiler, even though it is based on 80s technology, is quite helpful when developing Lisp code.