Syntactic sugar for object-oriented Lisp.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
~keith 9535f8c6ab oopsie that paragraph should have been before the other one 2 months ago
.gitignore Initial commit 2 months ago
LICENSE Initial commit 2 months ago
README.md oopsie that paragraph should have been before the other one 2 months ago
objective-lisp.asd 2.0 syntax 2 months ago
objective-lisp.lisp 2.0 syntax 2 months ago

README.md

objective-lisp

Syntactic sugar for object-oriented Lisp.

objective-lisp provides a simple, concise, and (slightly) more conventional syntax for accessing the slots and methods of objects. It defines a reader macro for the [ and ] characters (although you can change these in the code).

Usage

TL;DR: [object (method args)] is like object.method(args) in C++.

First, to enable objective-lisp's syntax, just load the system:

(asdf:load-system 'objective-lisp)

objective-lisp's syntax takes the form of a special S-expression, contained in square brackets rather than parentheses. Each expression within acts upon the result of the previous one, like a chain of . (dot) operators in C-like languages.

[foo (bar) (baz) (quux)]
;; C++: foo.bar().baz().quux()

To call a method, just write it after the object:

[object (method args...)]
;; => (method object args...)

Under the hood, this just passes object as the first argument to method, so you can do stuff like this (I won't kinkshame you, but your coworkers might):

[object (slot-value 'slot-name) (setf value)]
;; => [(slot-value object 'slot-name) (setf value)]
;;  => (setf (slot-value object 'slot-name) value)

Slot accessors, and other methods that don't take additional arguments, can be written without enclosing parentheses:

[object get-something]
;; => (get-something object)

To access slots directly, use the :slot keyword:

[object :slot slot-name]
;; => (slot-value object 'slot-name)

License

objective-lisp is public domain (CC0). You can do whatever you want with it. I don't really care about credit, it's just a silly little thing I wrote in a few hours. (And then rewrote just now because the syntax sucked.)

But if you find it useful, please let me know. I'd love to hear about it.