From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?B?S2FpIEdyb8Ofam9oYW5u?= Newsgroups: gmane.emacs.help Subject: Re: DynamicBindingVsLexicalBinding Date: Mon, 14 Oct 2013 23:32:09 +0200 Message-ID: <525C62D9.8070702@gmx.net> References: <52598D4A.2010901@easy-emacs.de> <871u3qjq0j.fsf@yandex.ru> <525A51BD.5040903@easy-emacs.de> <525AA42B.6030006@gmx.net> <6d5df021-be1e-40a2-966a-548a7ee9deb3@default> <87txgk85em.fsf@zerg32.ncl.ac.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1381786314 14033 80.91.229.3 (14 Oct 2013 21:31:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Oct 2013 21:31:54 +0000 (UTC) Cc: help-gnu-emacs@gnu.org To: Phillip Lord Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Oct 14 23:31:56 2013 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VVpk4-0001kH-9B for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Oct 2013 23:31:56 +0200 Original-Received: from localhost ([::1]:38839 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVpk3-0006ML-NG for geh-help-gnu-emacs@m.gmane.org; Mon, 14 Oct 2013 17:31:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVpjl-0006Lz-5o for help-gnu-emacs@gnu.org; Mon, 14 Oct 2013 17:31:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVpjd-0004QV-Sh for help-gnu-emacs@gnu.org; Mon, 14 Oct 2013 17:31:37 -0400 Original-Received: from mout.gmx.net ([212.227.15.15]:57571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVpjd-0004QA-JV for help-gnu-emacs@gnu.org; Mon, 14 Oct 2013 17:31:29 -0400 Original-Received: from marcie.lan ([188.100.165.77]) by mail.gmx.com (mrgmx001) with ESMTPSA (Nemesis) id 0LrNl6-1VsykF2UIe-0139kS for ; Mon, 14 Oct 2013 23:31:27 +0200 User-Agent: Postbox 3.0.8 (Macintosh/20130427) Original-Newsgroups: gmane.emacs.help In-Reply-To: <87txgk85em.fsf@zerg32.ncl.ac.uk> X-Provags-ID: V03:K0:yGA/3KYeH+S0FXghEYxAOn3eNFr06vYIPJsHNbzMXyfqS5zBhSs S+38z3H7U0AjKSRn1qk5pOkyLTQBsJRJeVm3NSWPXEnbtO0yT/BwcHsqhkt8hH4m8vjDnWP xqZyYp2oPX0HgV46y+u7Kf/7WPOYASAvOhsU6yQ9ld6+b8M4+wYnVGHPMnhTuGN5zB8bwLl VzEgZURYZbrOX8iioEn9Q== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.15.15 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:94016 Archived-At: 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