timowest / symbol

typed lisp adventure
17 stars 1 forks source link

Add deftype support #27

Open timowest opened 11 years ago

timowest commented 11 years ago

A subset of Clojure's deftype constructs could be supported

(deftype <name> <columns vector> & <functions>)

e.g.

(deftype Person [contents]
  ; clojure.lang.IPersistentMap (no implements declarations for the moment)
  (assoc [_ k v] (Person. (.assoc contents k v)))
  (assocEx [_ k v] (Person. (.assocEx contents k v)))
  (without [_ k] (Person. (.without contents k))))
timowest commented 11 years ago

As generic classes can't be properly modeled using the current approach, they might need to be put into the struct list:

(struct <name> <generics> <members>)

and for generic types usage will also need to be encoded like this

(TypeName & generics)