Skip to content

Instantly share code, notes, and snippets.

@zkat
Last active August 29, 2015 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zkat/48891 to your computer and use it in GitHub Desktop.
Save zkat/48891 to your computer and use it in GitHub Desktop.
(defun slate-dispatch (selector &rest args)
(let ((n (length args))
(most-specific-method nil)
(ordering-stack nil))
(loop for index upto n
do (let ((position 0))
(push (elt args index) ordering-stack)
(loop while ordering-stack
do (let ((arg (pop ordering-stack)))
(loop for role in (roles arg)
(when (and (eql selector (name role))
(eql index (role role)))
(setf most-specific-method (talent-pointer role))))
(loop for delegation in (sheep-direct-parents arg)
do (push delegation ordering-stack))
(setf position (1+ position))))))
most-specific-method))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment