Re: Parsec parser library...

"David McClain (as dbm at refined-audiometrics dot com)" <[email protected]> Mon, 27 Jul 2026 08:28:12 -0700
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
Looks like you are similar to mine: Keeping it looking like a LOL, although I do it with TLET, instead of the arg.

I use a SYMBOL-MACROLET to keep the syntax looking like a lexical binding in use. 

THe one thing I ran into immediately was that you have to be sure that SMP is actually running, in order to use MP:PROCESS-PRIVATE-PROPERTY. I now look for that exceptional case, and resort to a LOL holding hash table, if needed. I apparently did need it for my number parsing while loading up my normal working image.



> On Jul 27, 2026, at 07:24, Tim Bradshaw (as tfb at tfeb dot org) <[email protected]> wrote:
> 
> On 27 Jul 2026, at 06:45, David McClain (as dbm at refined-audiometrics dot com) <[email protected]> wrote:
>> 
>> So we need some kind of thread-local version of Let-Over-Lambda.
> 
> For things like this I tend to use some variant of
> 
> (defun make-tval (&optional (default nil))
>  (let ((table (make-hash-table :weak-kind :key)))
>    (lambda (thread &optional (nv nil nvp))
>      (if nvp
>          (setf (gethash thread table) nv)
>        (gethash thread table default)))))
> 
> (declaim (inline tval-value (setf tval-value)))
> 
> (defun tval-value (tval &optional (thread *current-process*))
>  (funcall tval thread))
> 
> (defun (setf tval-value) (new tval &optional (thread *current-process*))
>  (funcall tval thread new))
> 
> Assuming hash-table access is thread-safe this is OK I think.  And then you do something like.
> 
> (let ((something (make-tval <default>)))
>  (lambda (...)
>    ... (tval-value something) ... (setf (tval-value something) ...) ...))
> 
> I like it that the solution is itself let over lambda.
> 
> 
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> [email protected]
> http://www.lispworks.com/support/lisp-hug.html


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html