From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Matthias Koeppe Newsgroups: gmane.lisp.guile.user Subject: Re: defining new character names? Date: Wed, 21 Aug 2002 10:51:38 +0200 Sender: guile-user-admin@gnu.org Message-ID: References: <20020819100733.GA6177@sim.no> <871y8uxvyd.fsf@zagadka.ping.de> <200208200340.g7K3e7I01435@fcs9.free-comp-shop.com> <20020821081209.GB31070@sim.no> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1029919933 7855 127.0.0.1 (21 Aug 2002 08:52:13 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 21 Aug 2002 08:52:13 +0000 (UTC) Cc: Keith Wright , mvo@zagadka.ping.de, guile-user@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17hRDn-00022a-00 for ; Wed, 21 Aug 2002 10:52:12 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17hREn-0003fz-00; Wed, 21 Aug 2002 04:53:13 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17hRDs-0003NC-00 for guile-user@gnu.org; Wed, 21 Aug 2002 04:52:16 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17hRDM-00038i-00 for guile-user@gnu.org; Wed, 21 Aug 2002 04:52:15 -0400 Original-Received: from saturn.math.uni-magdeburg.de ([141.44.75.38]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17hRDL-00037j-00 for guile-user@gnu.org; Wed, 21 Aug 2002 04:51:43 -0400 Original-Received: from beta.math.uni-magdeburg.de (beta [141.44.75.78]) by saturn.math.uni-magdeburg.de (8.11.6/8.11.6) with ESMTP id g7L8pdX05311; Wed, 21 Aug 2002 10:51:39 +0200 (MET DST) Original-Received: (from mkoeppe@localhost) by beta.math.uni-magdeburg.de (8.10.2+Sun/8.10.2) id g7L8pcQ28998; Wed, 21 Aug 2002 10:51:38 +0200 (MEST) X-Authentication-Warning: beta.math.uni-magdeburg.de: mkoeppe set sender to mkoeppe@mail.math.uni-magdeburg.de using -f Original-To: "Lars J. Aas" In-Reply-To: <20020821081209.GB31070@sim.no> ("Lars J. Aas"'s message of "Wed, 21 Aug 2002 10:12:10 +0200") Original-Lines: 66 User-Agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1.80 (sparc-sun-solaris2.7) Errors-To: guile-user-admin@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.user:823 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:823 "Lars J. Aas" writes: > The most "transparent" solution would be to allow > > (define #\paren-close #\051) > > [If the first token looks like a character constant, the second must > be one too?] Would that be possible to implement without any overhead > on the define implementation? Would it break something? It would break everything. DEFINE does not operate on "tokens". You seem to be missing that there are two phases when you feed forms into Guiles: 1. The reader reads the string "(define paren-close-character #\051)". It turns the tokens "define" and "paren-close-character" into symbols and handles the read-syntax "#\", turning "#\051" into a character object. It returns a list of two symbols and a character object. 2. The evaluator evaluates this list. Because in your example #\paren-close is not known read-syntax, the reader will signal an error. As I wrote before, I believe you are misunderstanding the role of the #\ read syntax. It is not meant as a syntax for character constants; rather it is a way to specify literal characters, like #\c There is also no special syntax for string constants, or integer constants in Guile; there only is read syntax for literal strings, like =20=20=20=20=20=20=20=20 "Error", and literal numbers,=20 314159265. If you want to create a named constant, you simply do (define error-message "Error") (define scaled-pi 314159265) =20=20=20 In the same way, you do =20=20=20 (define paren-close-char #\051) or (define paren-close-char (integer->char 41)) What I think _would_ be useful for Guile is a new DEFINE form that creates constant variables, like DEFINE-CONSTANT, so you could say =20=20=20=20=20=20=20=20 (define-constant paren-close-char (integer->char 41)). This may serve useful for compiler optimizations, because the compiler (if any) could assume that the value of the variable never changes. Regards, --=20 Matthias K=F6ppe -- http://www.math.uni-magdeburg.de/~mkoeppe _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user