From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Neil Jerram Newsgroups: gmane.lisp.guile.devel Subject: Re: doc expression syntax, quoting Date: 16 Feb 2004 20:08:32 +0000 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: References: <873c9c0z6k.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1076962989 2123 80.91.224.253 (16 Feb 2004 20:23:09 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 16 Feb 2004 20:23:09 +0000 (UTC) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Feb 16 21:22:52 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AspGW-0008Ug-00 for ; Mon, 16 Feb 2004 21:22:52 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AspGO-00076R-8q for guile-devel@m.gmane.org; Mon, 16 Feb 2004 15:22:44 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AspE1-0005Us-2i for guile-devel@gnu.org; Mon, 16 Feb 2004 15:20:17 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AspDQ-00053Y-T5 for guile-devel@gnu.org; Mon, 16 Feb 2004 15:20:13 -0500 Original-Received: from [80.84.72.14] (helo=mail2.uklinux.net) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AspDP-00051C-K3 for guile-devel@gnu.org; Mon, 16 Feb 2004 15:19:39 -0500 Original-Received: from laruns.ossau.uklinux.net (unknown [213.78.80.212]) by mail2.uklinux.net (Postfix) with ESMTP id CA30240A032 for ; Mon, 16 Feb 2004 20:19:32 +0000 (UTC) Original-Received: from laruns.ossau.uklinux.net.ossau.uklinux.net (localhost [127.0.0.1]) by laruns.ossau.uklinux.net (Postfix on SuSE Linux 7.2 (i386)) with ESMTP id 22943DC4D6 for ; Mon, 16 Feb 2004 20:08:33 +0000 (GMT) Original-To: guile-devel@gnu.org In-Reply-To: <873c9c0z6k.fsf@zip.com.au> Original-Lines: 128 User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.lisp.guile.devel:3389 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3389 >>>>> "Kevin" == Kevin Ryde writes: Kevin> This is some words to propose for the currently empty Expression Kevin> Syntax section of the manual. In particular it describes quote and Kevin> quasiquote, which don't otherwise appear in the manual. Nice; just a few comments below. Kevin> Expression Syntax Kevin> ================= Kevin> An expression to be evaluated takes one of the following forms. Kevin> - syntax: Kevin> A symbol is evaluated by dereferencing. A binding of that symbol Kevin> is sought and the value there used. For example, Kevin> (define x 123) Kevin> x => 123 Kevin> - syntax: (proc [args ...]) Kevin> A parenthesised expression is a function call. PROC and each Kevin> argument are evaluated, then the function (which PROC evaluated Kevin> to) is called with those arguments. Kevin> The order in which PROC and the arguments are evaluated is Kevin> unspecified, so be careful when using expressions with side Kevin> effects. Kevin> (max 1 2 3) => 3 Kevin> (define (get-some-proc) min) Kevin> ((get-some-proc) 1 2 3) => 1 Kevin> The same sort of parenthesised form is used for a macro invocation, Kevin> but in that case the the macro is applied before evaluating the Kevin> arguments. See the descriptions of macros for more on this (*note Kevin> Macros::, and *note Syntax Rules::). This suggests the args will still be evaluated, which is often not true. How about "but in that case the arguments are not automatically evaluated". (Note also "the the" typo.) Kevin> - syntax: Kevin> Number, string, character and boolean constants evaluate "to Kevin> themselves", so can appear as literals. Kevin> 123 => 123 Kevin> 99.9 => 99.9 Kevin> "hello" => "hello" Kevin> #\z => #\z Kevin> #t => #t Kevin> Note that an application must not attempt to modify literal Kevin> strings, since they may be in read-only memory. Kevin> - syntax: quote data Kevin> - syntax: ' data Kevin> Quoting is used to obtain a literal symbol (instead of a variable Kevin> reference), a literal list (instead of a function call), or a Kevin> literal vector. ' is simply a shorthand for a `quote' form. For Kevin> example, Kevin> 'x => x Kevin> '(1 2 3) => (1 2 3) Kevin> '#(1 (2 3) 4) => #(1 (2 3) 4) Kevin> (quote x) => x Kevin> (quote (1 2 3)) => (1 2 3) Kevin> (quote #(1 (2 3) 4)) => #(1 (2 3) 4) Kevin> Note that an application must not attempt to modify literal lists Kevin> or vectors obtained from a `quote' form, since they may be in Kevin> read-only memory. Kevin> - syntax: quasiquote data Kevin> - syntax: ` data Kevin> Backquote quasi-quotation is like `quote', but selected Kevin> sub-expressions are evaluated. This is a convenient way to Kevin> construct a list or vector structure most of which is constant, Kevin> but at certain points should have expressions substituted. Kevin> The same effect can always be had with suitable `list', `cons' or Kevin> `vector' calls, but quasi-quoting is often easier. Kevin> - syntax: unquote expr Kevin> - syntax: , expr Kevin> Within the quasiquote DATA, `unquote' or `,' indicates an Kevin> expression to be evaluated and inserted. The comma syntax `,' Kevin> is simply a shorthand for an `unquote' form. For example, Kevin> `(1 2 ,(* 9 9) 3 4) => (1 2 81 3 4) Kevin> `(1 (unquote (+ 1 1)) 3) => (1 2 3) Kevin> `#(1 ,(/ 12 2)) => #(1 6) Kevin> - syntax: unquote-splicing expr Kevin> - syntax: , expr Should be ,@ here. Kevin> Within the quasiquote DATA, `unquote-splicing' or `,@' Kevin> indicates an expression to be evaluated and the elements of Kevin> the returned list inserted. EXPR must evaluate to a list. Kevin> The "at-comma" syntax `,@' is simply a shorthand Kevin> for an Surely "comma-at", not "at-comma"? Kevin> `unquote-splicing' form. Kevin> (define x '(2 3)) Kevin> `(1 ,@x 4) => (1 2 3 4) Kevin> `(1 (unquote-splicing (map 1+ x))) => (1 3 4) Kevin> `#(9 ,@x 9) => #(9 2 3 9) Kevin> Notice `,@' differs from plain `,' in the way one level of Kevin> nesting is stripped. For `,@' the elements of a returned list Kevin> are inserted, whereas with `,' it would be the list itself Kevin> inserted. Kevin> _______________________________________________ Kevin> Guile-devel mailing list Kevin> Guile-devel@gnu.org Kevin> http://mail.gnu.org/mailman/listinfo/guile-devel _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel