4 ms·
Racket [http://www.racket-lang.org http://www.racket-lang.org] is a modern Lisp with STATIC TYPING. Quote from the static typing example on home page: Racket'
by spdegabrielle 13y ago
Racket [http://www.racket-lang.org http://www.racket-lang.org] is a modern Lisp with STATIC TYPING.
Quote from the static typing example on home page:
Racket's type system is designed to let you add types after you've worked for a while in untyped mode — even if your untyped program wouldn't fit nicely in a conventional type system.
#lang typed/racket
;; Using higher-order occurrence typing
(define-type SrN (U String Number))
(: tog ((Listof SrN) -> String))
(define (tog l)
(apply string-append (filter string? l)))
(tog (list 5 "hello " 1/2 "world" (sqrt -1)))
To run the example, install Racket, start DrRacket, paste the example program into the top area in DrRacket, and click the Run button. Alternatively, save the program to a file and run racket on the file.
- brudgers 13y agoHell, you don't even need to use typed/racket to implement static types. You can just use contracts with plain old Racket to achieve true lispyness...because contracts let you impose static type-checking selectively within your code and for staticly-typed code to symbiose with dynamically-typed code. Racket Guide on contracts: http://docs.racket-lang.org/guide/contracts.html http://docs.racket-lang.org/guide/contracts.html Racket Reference on contracts: http://docs.racket-lang.org/reference/contracts.html http://docs.racket-lang.org/reference/contracts.html There's even this groovy academic paper: http://www.eecs.northwestern.edu/~robby/pubs/papers/oopsla2012-stff.pdf http://www.eecs.northwestern.edu/~robby/pubs/papers/oopsla20... It almost goes without saying that contracts are the mechanism by which typed/racket is statically typed.
- hajile 13y agoShen is a lisp dialect with a turing complete type system and lazy typing (both of which are optional for maximum programmer flexibility). http://shenlanguage.org/index.html http://shenlanguage.org/index.html
- xenophonf 13y agoCommon Lisp is a modern Lisp with static typing, too. For example, here's compile-time type checking performed by the SBCL compiler: * (defun test (x) (declare (fixnum x)) (the string x)) ; in: DEFUN TEST ; (THE STRING X) ; ; caught WARNING: ; Derived type of X is ; (VALUES FIXNUM &OPTIONAL), ; conflicting with its asserted type ; STRING. ; See also: ; The SBCL Manual, Node "Handling of Types" ; ; compilation unit finished ; caught 1 WARNING condition STYLE-WARNING: redefining COMMON-LISP-USER::TEST in DEFUN TEST * (test 1) debugger invoked on a SIMPLE-TYPE-ERROR: Value of X in (THE STRING X) is 1, not a STRING. Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL. restarts (invokable by number or by possibly-abbreviated name): 0: [ABORT] Exit debugger, returning to top level. (SB-C::%COMPILE-TIME-TYPE-ERROR (1) STRING #<unavailable argument> ((THE STRING X) X)) 0] 0