From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.help Subject: common data defined once for several functions without making it global with lexical-let and fset Date: Fri, 25 Jul 2014 17:05:13 +0200 Organization: Aioe.org NNTP Server Message-ID: <87k371mqc6.fsf@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1406301028 16719 80.91.229.3 (25 Jul 2014 15:10:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 25 Jul 2014 15:10:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 25 17:10:22 2014 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 1XAh8V-0008Qx-Fg for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Jul 2014 17:10:19 +0200 Original-Received: from localhost ([::1]:55322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAh8U-0005bn-Oy for geh-help-gnu-emacs@m.gmane.org; Fri, 25 Jul 2014 11:10:18 -0400 Original-Path: usenet.stanford.edu!newsfeed.news.ucla.edu!news.snarked.org!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 33 Original-NNTP-Posting-Host: SIvZRMPqRkkTHAHL6NkRuw.user.speranza.aioe.org Original-X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-Notice: Filtered by postfilter v. 0.8.2 Cancel-Lock: sha1:pINCmBzPfl+ZCYYfr6t7sSeiSkw= Mail-Copies-To: never Original-Xref: usenet.stanford.edu gnu.emacs.help:206672 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:98946 Archived-At: If `defun' isn't used, it can be solved with `lexical-let'. (lexical-let ((msg "shared inside")) (fset 'func-a (lambda (arg) "Number one." (message "1: %s" msg))) (fset 'func-b (lambda (arg) "Number two." (message "2: %s" msg))) ) (func-a 1) (func-b 2) The code gets less pleasant to write and read and it seems to confuse the help system: func-a is a Lisp function. (func-a &rest --CL-REST--) Number one. And, the byte-compiler doesn't like this solution any more than the `setq' one: In toplevel form: funs.el:1:1:Warning: `(msg "shared inside")' is a malformed function funs.el:2:45:Warning: reference to free variable `msg' In end of data: funs.el:7:1:Warning: the following functions are not known to be defined: lexical-let, func-1, func-2 Wrote /home/incal/funs.elc -- underground experts united