Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: f5e912fdbf
Fetching contributors…

Cannot retrieve contributors at this time

21 lines (17 sloc) 0.598 kB
(in-package :parser-combinators)
;;; emulate laziness as well, otherwhise any sort of recursion fails hard
(defclass promise ()
((thunk :accessor thunk-of :initarg :thunk)
(value :accessor value-of :initform nil)))
(defmacro delay (&body body)
`(make-instance 'promise
:thunk #'(lambda ()
,@body)))
(defun force (promise)
(with-accessors ((value value-of) (thunk thunk-of)) promise
(if thunk
(let ((real-value (funcall thunk)))
(setf value real-value
thunk nil)
real-value)
value)))
Jump to Line
Something went wrong with that request. Please try again.