From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ralph Schleicher Newsgroups: gmane.emacs.bugs Subject: bug#2951: Suggestion: self-evaluating-p function Date: Sat, 11 Apr 2009 23:35:04 +0200 Organization: Ralph Schleicher, Freelance Engineer Message-ID: <87r5zy7u2f.fsf@echo.mueller-schleicher.i> References: <87myaogpr8.fsf@echo.mueller-schleicher.i> Reply-To: Ralph Schleicher , 2951@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1239487481 19167 80.91.229.12 (11 Apr 2009 22:04:41 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 11 Apr 2009 22:04:41 +0000 (UTC) Cc: 2951@emacsbugs.donarmstrong.com, Ralph Schleicher To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 12 00:05:56 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1LslKJ-0006Cm-4j for geb-bug-gnu-emacs@m.gmane.org; Sun, 12 Apr 2009 00:05:48 +0200 Original-Received: from localhost ([127.0.0.1]:35267 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LslIu-00049Z-Sc for geb-bug-gnu-emacs@m.gmane.org; Sat, 11 Apr 2009 18:04:00 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LslIq-00049C-EC for bug-gnu-emacs@gnu.org; Sat, 11 Apr 2009 18:03:56 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LslIm-00048x-Rh for bug-gnu-emacs@gnu.org; Sat, 11 Apr 2009 18:03:56 -0400 Original-Received: from [199.232.76.173] (port=44754 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LslIm-00048u-L4 for bug-gnu-emacs@gnu.org; Sat, 11 Apr 2009 18:03:52 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:48881) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LslIm-0004Aw-1F for bug-gnu-emacs@gnu.org; Sat, 11 Apr 2009 18:03:52 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n3BM3nEx001854; Sat, 11 Apr 2009 15:03:49 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n3BLj3Rf029463; Sat, 11 Apr 2009 14:45:03 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Ralph Schleicher Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Sat, 11 Apr 2009 21:45:03 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 2951 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 2951-submit@emacsbugs.donarmstrong.com id=B2951.123948571728073 (code B ref 2951); Sat, 11 Apr 2009 21:45:03 +0000 Original-Received: (at 2951) by emacsbugs.donarmstrong.com; 11 Apr 2009 21:35:17 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from nsi67.de (nsi67.de [85.31.187.140]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n3BLZ7xo027305 for <2951@emacsbugs.donarmstrong.com>; Sat, 11 Apr 2009 14:35:09 -0700 Original-Received: from bravo.mueller-schleicher.i (p57ADFE52.dip.t-dialin.net [87.173.254.82]) by nsi67.de (Postfix) with ESMTP id 397CF780357; Sat, 11 Apr 2009 23:35:09 +0200 (CEST) Original-Received: from echo.mueller-schleicher.i (echo [192.168.178.5]) by bravo.mueller-schleicher.i (Postfix) with ESMTP id 0FCADFC7E5; Sat, 11 Apr 2009 23:35:05 +0200 (CEST) Original-Received: by echo.mueller-schleicher.i (Postfix, from userid 1000) id B6E3B4B00B8; Sat, 11 Apr 2009 23:35:04 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Sat\, 11 Apr 2009 08\:53\:45 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Sat, 11 Apr 2009 18:03:56 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:27100 Archived-At: Stefan Monnier writes: >> I would like to have a 'self-evaluating-p' function in Emacs to check >> whether or not a value has to be quoted. > > I'm not necessarily opposed, but I'd first hear some arguments > explaining why/when one would need that. Okay, this is probably best explained by an example. I'm working on an Emacs package for parsing numbers in a flexible way. That means the regular expression string matching a number is a function of the selected numeral system and set of numbers to match. While some numeral systems have really different notations for numbers, other systems are quite close to each other. This is especially true for numeral systems of programming languages. Therefore it is natural to define related numeral systems by inheritance: (define-numeral-system Fortran '((number-numerals "0123456789") (number-zero "0") (number-plus "+") (number-minus "-") (number-radix ".") (number-exponent "DEde") ;; ... ) "Numeral system for the Fortran programming language.") (define-numeral-system C (with-numeral-system 'Fortran (setq number-exponent "Ee") ;; ... (numeral-system-bindings t)) "Numeral system for the C programming language.") The 'with-numeral-system' macro and 'numeral-system-bindings' function are defined as follows. (defmacro with-numeral-system (name &rest body) "Evaluate BODY within numeral system NAME." `(let ,(numeral-system-bindings (eval name)) ,@body)) (defun numeral-system-bindings (name) "Return the variable bindings for a numeral system. Argument NAME is the symbolic name of a numeral system (a symbol). A value of nil means to bind all symbols to nil, t means to bind all symbols to their current value, and `default' means to bind all symbols to their default values. Return value is a `let'-like list of variable bindings." (cond ;; ... ((eq name t) (let (value) (mapcar (lambda (symbol) (setq value (symbol-value symbol)) ;;;; ==> (list symbol (if (self-evaluating-p value) value (list 'quote value)))) numeral-system-variables))) ;; ... )) I noticed that if I don't check for a self-evaluating form here, the variable bindings for a numeral system are improperly quoted in the alist of numeral systems. I hope these explanations are clear enough. -- Ralph