IRC channel logs

2024-07-13.log

back to list of logs

<flatwhatson>fnat: you can use guile's lower-level records facility to query the fields of a record type
<flatwhatson>(define-record-type <foo> (make-foo bar) foo? (bar foo-bar))
<flatwhatson>(record-type-fields <foo>) ;=> (bar)
<flatwhatson>so you can do the following:
<flatwhatson>(define (make-alist->record type)
<flatwhatson> (let ((constructor (record-constructor type))
<flatwhatson> (fields (record-type-fields type)))
<flatwhatson> (lambda (alist)
<flatwhatson> (apply constructor (map (lambda (field)
<flatwhatson> (assq-ref alist field))
<flatwhatson> fields)))))
<flatwhatson>(define alist->foo (make-alist->record <foo>))
<flatwhatson>(alist->foo '((bar . 1))) ;=> #<<foo> bar: 1>
<rlb>wingo: filed bugs for the pending 3.0.10 fixes - https://debbugs.gnu.org/72084 https://debbugs.gnu.org/72085 https://debbugs.gnu.org/72086 (that were on the list)
<graywolf>Hello :) Are modules ever garbage collected?
<fnat>This is brilliant, thanks flatwhatson!
<graywolf>Is there something like parametrize but for regular variables? I know I can use dynamic-wind, but it is bit verbose, so I wondered if there is a built-in helper for it...
<flatwhatson>graywolf: parameterize for regular bindings is let
<haugh>Do syntax parameters actually require that the keyword be exported to the user as a top-level binding?
<graywolf>flatwhatson: in elisp with dynamic scope sure, but (let ((%fresh-auto-compile #t)) (load ...)) will not work no?
<haugh>I think I understand; similar to my beef with srfi-42, the idea is that the expansion happens in the context of the user module. So in the context of SPs, the user has to have lexical access to the unmodified parameter in order to parameterize it. I was trying to use SPs to avoid writing a general recursive descent transformer. Guess it's time to bite the bullet