Quantcast
Channel: Hacker News 50
Viewing all articles
Browse latest Browse all 9433

Taf - A plan for a statically-typed Lisp

$
0
0

Comments:"Taf - A plan for a statically-typed Lisp"

URL:http://manuel.github.com/taf/doc/plan.html


Taf is a new Lisp that employs row polymorphism, found in such languages as O'Caml and MLPolyR, to enable a programming style that is fully type-safe, while maintaining Lisp's low overhead wrt. type system bureaucracy. Row polymorphism enables the use of tagged records with named fields, without having to predeclare record tags, as well as open generic functions, to which methods can be added. Both features are fully type-safe: all accesses to non-existing fields, as well as calls to generic functions for which no matching method exists are detected statically during type-checking. Note that the resulting system is even more dynamic-feeling than Lisp - we don't even need to use define-record, define-class, or similar anymore.

For example, this code is statically type-checkable, while being similar to existing dynamically type-checked Lisp:

(define (make-person name email)
 #(person :name name :email email)) ; creates a person record with name and email fields
(define-generic (to-string obj))
(define-method (to-string (obj #(person :name :email))) ; matches persons and binds name and email field to local variables
 (concat (list name " <" email ">")))
(to-string (make-person "Manuel" "msimoni@gmail.com"))
; ==> "Manuel <msimoni@gmail.com>"

(Note the absence of any record type declaration for persons, while full type safety is maintained.)

Taf employs a combination of Common Lisp's first-order control flow (block, return-from, unwind-protect) and multi-prompt dynamicdelimited continuations (push-prompt, take-subcont,push-subcont). Taf is not properly tail recursive, so an infiniteloop is provided.

For syntactic abstraction, Taf uses hygienic procedural macros, using a novel macro system inspired by Kernel's fexprs.

Taf is currently vaporware, but actively being developed. The plan for the first iteration is:

  • Translate Taf code to MLPolyR for type-checking.
  • Interpret Taf code in JavaScript for interactive evaluation (the in-browser REPL will probably talk to a MLPolyR "type-check server"). This will use mostly the same techniques as Wat.

Taf is hosted at https://github.com/manuel/taf.

Author: Manuel Simoni<msimoni@gmail.com>

Date: 2013-01-14 22:12:18 CET


Viewing all articles
Browse latest Browse all 9433

Trending Articles