Skip to content

Instantly share code, notes, and snippets.

@southly
Created January 20, 2011 12:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save southly/787808 to your computer and use it in GitHub Desktop.
Save southly/787808 to your computer and use it in GitHub Desktop.
#xyzzy
(defmacro define-tco-function (name (&rest lambda-list) &body body)
(let ((continue (gensym "continue"))
(vals (mapcar #'(lambda (x) (if (consp x) (car x) x))
(remove-if (lambda (x) (member x lambda-list-keywords))
lambda-list))))
`(defun ,name ,lambda-list
(macrolet ((,name (&rest args)
(list 'progn
(list 'multiple-value-setq ',vals (cons 'values args))
(list 'go ',continue))))
(tagbody
,continue
(return-from
,name
(progn ,@body)))))))
@southly
Copy link
Author

southly commented Jan 20, 2011

引数のラムダリストの処理は手抜き。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment