Code: Select all
x=56
y="string"
z= (format t "~a ~a" x y)
I could just be missing something I guess, and I'm not proposing another language. Just random daydreaming while bored.
Code: Select all
x=56
y="string"
z= (format t "~a ~a" x y)
Code: Select all
(defmacro let-follow (vars &body body)
"Variables that act like functions."
(let*((functions ;;Paired functions. (looking into them to see which gensym.)
(mapcar (lambda (var &key (gs (gensym)))
`((,gs () ;;Function to get variable.
(or ,gs ,(cadr var)))
((setf ,gs) (to) ;;Function to set variable.
(setf ,gs to))))
vars))
(genvars (mapcar #'caar functions)))
`(let*(,@genvars);Make the symbols refer to the functions.
(declare (ignorable ,@genvars))
(symbol-macrolet (,@(mapcar (lambda (var fun)
`(,(car var) (,(caar fun))))
vars functions))
;Flatten out functions into labels. (unlike flet these are allowed to depend on eachother.)
(labels (,@(mapcan #'identity functions))
(declare (ignorable ,@(mapcan (lambda (var)
`((function ,var)
(function (setf ,var))))
genvars)))
,@body)))))
(let-follow ((x 0) (y 5) (z (+ x y)))
(print z) ;;Weirdly enough setq works, guessing symbolmacros change to counter potential confusion.
(print (setq x 3))
(print z)))
Code: Select all
x="test string"
Code: Select all
y(what)= (format t "This is a ~a" what)
Code: Select all
obj = object
Code: Select all
obj(name) = object
obj.name=name
obj.age=46
obj.alive= t
Code: Select all
obj.explode = (format t "Boom!")
obj.alive= nil
Code: Select all
(defmacro =body (&body body)
"Allow := to define variables/functions at the start of bodies."
(let ((i (position := body)))
(typecase i
((eql 1)
`(let ((,(car body) ,(caddr body))) (=body ,@(cdddr body))))
((eql 2)
(destructuring-bind (name args = fun &body body) body
(assert (eql = :=))
`(flet ((,name ,args ,fun))
(=body ,@body))))
(null
`(progn ,@body)))))
(=body a := 1 b := 4
a+b (x) := (* x a b)
(+ a b (a+b 3)))
(defmacro def (name args = &body body)
(assert (eql = :=))
`(defun ,name ,args (=body ,@body)))
(macroexpand-1 '(def sqr (x) := (* x x)))
Code: Select all
thing(name) =
.name=name
.age=46
.alive= t
Code: Select all
thing(name) =
add other-object
.name=name
.age=46
.alive= t