Skip to content

missingfaktor/stuff.clj

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stuff.clj

This is a result of me exploring modeling of an object system atop Clojure primitives, on a rather undecisive holiday. The motivation is to understand PL concepts better, and to scratch some itch. This project is not intended for any serious use.

There is not much here at the moment, but I plan to work on this as and when I find time.

I am not going to get anywhere with this endeavor, unless I read the following books:

  1. The Art of the Metaobject Protocol
  2. The Why of Y
  3. Haskell's overlooked object system

Example code

(define-class Person [name age sex self]
              :name name
              :age age
              :sex sex

              :adult?
              (fn []
                (> (get-attr self :age) 18))

              :older-than?
              (fn [other]
                (> (get-attr self :age)
                   (get-attr other :age))))

(def ashok
  (instantiate Person "Ashok" 20 :male))

(def jaya
  (instantiate Person "Jaya" 17 :female))

(invoke ashok :adult?)

(invoke ashok :older-than? jaya)

(map #(get-attr % :sex) [jaya ashok])

License

Copyright © 2014 FIXME

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

About

A simple object system atop simple primitives

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published