| Some of you will have these primitives (or variants) in your toolbox. Can you think of a better name for any of them? (awhile, proc and especially ret seem pretty settled) (mac awhile(expr . body)
`(whilet it ,expr
,@body))
(mac forever body
`(awhile t ,@body))
(mac proc(name args . body)
`(def ,name ,args ,@body nil))
; skenney26: http://arclanguage.org/item?id=11068
(mac ret(var val . body)
`(let ,var ,val ,@body ,var))
; aw: http://awwx.ws/dyn
(mac dynvar (name (o init))
(w/uniq (param val)
`(withs (,val ,init
,param (ac-scheme (make-parameter ,val)))
(defvar ,name ,param))))
(mac dlet (var value . body)
(w/uniq (param v f)
`(with (,param (defvar-impl ,var)
,v ,value
,f (fn () ,@body))
(ac-scheme (parameterize ((,param ,v)) (,f))))))
; various
(mac before-exec(fnname args . body)
`(let old ,fnname
(def ,fnname ,args
,@body
(old ,@args))))
(mac after-exec(fnname args . body)
`(let old ,fnname
(def ,fnname ,args
(let result (old ,@args)
,@body
result))))
; palsecam: http://arclanguage.org/item?id=10696
(= buffered-exec-delay* 10)
(= buffered-execs* (table))
(def buffered-exec(f)
(or= buffered-execs*.f
(thread (sleep buffered-exec-delay*)
(wipe buffered-execs*.f)
(f))))
; http://arclanguage.org/item?id=11103
(mac init args
`(unless (bound ',(car args))
(= ,@args)))
(mac ifcall(var)
`(if (bound ',var)
(,var)))
Feel free to show off your own favorite utilities. The arc community needs a growing shared vocabulary for common operations more than it needs a new compiler or anarki, IMO. |