help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DynamicBindingVsLexicalBinding


From: Kai Großjohann
Subject: Re: DynamicBindingVsLexicalBinding
Date: Mon, 14 Oct 2013 23:32:09 +0200
User-agent: Postbox 3.0.8 (Macintosh/20130427)

Phillip Lord wrote:
> 
> I've certainly used the feature that Kai likes, but mostly it has been
> to hack around code which I do not control or do not want to change.
> Nowadays, in general, I would want to advice code instead.

Here is a nice and straightforward application of dynamic binding (if I
do say so myself).

(defun perldoc ()
  (interactive)
  (require 'man)
  (let ((manual-program "perldoc"))
    (call-interactively 'man)))

The part where it does call-interactively is pretty ugly (but the full
interactive spec of the man function is even worse).

Of course a REAL developer would provide a manual reader class with
configurable manual reader class factories, and then use a dependency
injection container to implement a configurable manual reader class
factory factory.  And because convention over configuration is a good
thing, we'll say that the ManManualReaderFactory creates "man" manual
readers whereas the PerldocManualReaderFactory creates "perldoc" manual
readers.  So you can write a manual reader factory factory generator
that just generates an empty subclass of the
AbstractManualReaderFactoryBase at runtime.  Yeah.  That would be great.
 You would even only need a few hundred lines of code to do it.  And the
Spring dependency injection container to go with it is only a couple MB.
 What's not to like about this?  What?  The Emacs Lisp solution is only
five lines of code you say?  How can this _possibly_ provide the same
functionality that we've got with our awesome enterprisey framework?
Hm?  Dynamic binding?  You must be kidding!

Kai



reply via email to

[Prev in Thread] Current Thread [Next in Thread]