[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Elisp printer
From: |
Stefan Monnier |
Subject: |
Re: Elisp printer |
Date: |
Tue, 07 Mar 2017 23:39:55 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
> I was wondering about this a while ago and thinking that maybe it could
> be done without C changes by repurposing the extra arguments to
> make-byte-code. The idea here would be to let cl-defsubst take a new
> :type argument other than 'vector or 'list, meaning "use
> make-byte-code"; and set the :initial-offset to skip over the stuff
> necessary for the bytecode.
Yes, that can be done fairly easily. But that doesn't give you callable
functions: it just gives you structs represented by those special
"compiled-function" vectors.
E.g. thunk.el creates its thunks with:
(defmacro thunk-delay (&rest body)
"Delay the evaluation of BODY."
(declare (debug t))
(let ((forced (make-symbol "forced"))
(val (make-symbol "val")))
`(let (,forced ,val)
(lambda (&optional check)
(if check
,forced
(unless ,forced
(setf ,val (progn ,@body))
(setf ,forced t))
,val)))))
so we'd need some way to specify both the function's body and its
"struct" at the same time. What I was thinking of was something like
(callable-defstruct thunk
val forced)
(defmacro thunk-delay (&rest body)
"Delay the evaluation of BODY."
(declare (debug t))
`(make-thunk (&optional check)
(if check
forced
(unless forced
(setq val (progn ,@body))
(setq forced t))
val)))
The idea would be that `forced` and `val` would be fields of the
"callable-struct" and would be accessible directly from the body of the
function (as well as from the outside via thunk-val and thunk-forced
accessors). That would require changes to the byte-compiler (mostly in
cconv.el) but it can probably be made to work without significant
changes at the C level.
Stefan
- Elisp printer (was: bug#25295: Represent eieio objects using object-print in backtraces and edebug), Michael Heerdegen, 2017/03/02
- Re: Elisp printer, Tom Tromey, 2017/03/07
- Re: Elisp printer, Lars Brinkhoff, 2017/03/08
- Re: Elisp printer, Stefan Monnier, 2017/03/08
- Re: Elisp printer, Lars Brinkhoff, 2017/03/09
- User-defined record types, Lars Brinkhoff, 2017/03/14
- Re: User-defined record types, Lars Brinkhoff, 2017/03/14
- Message not available
- Message not available
- Re: User-defined record types, Lars Brinkhoff, 2017/03/14
- Re: User-defined record types, Lars Brinkhoff, 2017/03/14
- Re: User-defined record types, Stefan Monnier, 2017/03/14