all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Daniel Colascione <dan.colascione@gmail.com>
To: Leo <sdl.web@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Make register easier to hook
Date: Mon, 28 Mar 2011 19:14:55 -0700	[thread overview]
Message-ID: <4D91409F.6030702@gmail.com> (raw)
In-Reply-To: <m1y63y3fzm.fsf@gmail.com>

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.)






  reply	other threads:[~2011-03-29  2:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28 15:35 Make register easier to hook Leo
2011-03-28 17:37 ` Daniel Colascione
2011-03-29  0:52   ` Leo
2011-03-29  2:14     ` Daniel Colascione [this message]
2011-03-28 17:39 ` Davis Herring
2011-03-31 10:37   ` Leo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D91409F.6030702@gmail.com \
    --to=dan.colascione@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=sdl.web@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.