[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Make register easier to hook
From: |
Daniel Colascione |
Subject: |
Re: Make register easier to hook |
Date: |
Mon, 28 Mar 2011 19:14:55 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
On 3/28/2011 5:52 PM, Leo wrote:
> On 2011-03-29 01:37 +0800, Daniel Colascione wrote:
>> Thanks for doing this work. An extensible register system is also on my
>> wishlist. Why did you decide to use the list for the register structure
>> instead of the default vector representation?
>
> Probably because it looks nicer inside register-alist and there is
> little performance to lose.
>
>> Also, have you considered eliminating the `info' slot? Users can
>> construct closures over any necessary variables and assign these
>> closures to the register structure's remaining function slots. After
>> all, we're getting lexbind, and this feature will make constructing
>> closures both easy and safe.
>
> Now I do. But I fail to see how that makes things more convenient. The
> closures must be created inside the command/function that creates the
> register, right? So one won't be able to define functions with defun for
> the slots. Did I miss something?
Well, when we get lexbind, we'll be able to write something like this
safely, cleanly, and efficiency:
(defun foo-register-jump (some-datum)
"Implement the jump operation for registers with foo values."
...
)
(defun foo-register-assign (register some-datum)
"Assign a foo register value to some register"
(register-set register
(register-make
:jump-func (lambda () (foo-register-jump some-datum))))
Today, we'd have to write this instead for the same effect:
(defun foo-register-assign (register some-datum)
"Assign a foo register value to some register"
(lexical-let ((some-datum some-datum)) ; <----- HACK -------<
(register-set register
(register-make
:jump-func (lambda () (foo-register-jump some-datum)))))
I still think the version with lexical-let is cleaner than using a
separate data value, especially because you can easily close over
multiple variables without having to build some aggregate data structure
to hold them.
By the way: I'd also suggest calling the structure register-value or
somesuch. It's confusing to have the same word refer to the *identifier*
for the register (a, b, c, ...) and for the thing *inside* a register (a
window configuration, a marker, a string, etc.)