From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Price Newsgroups: gmane.lisp.guile.user Subject: Re: Guile vectors Date: Wed, 09 Oct 2013 22:49:14 +0100 Message-ID: <87li22i085.fsf@Kagami.home> References: <878uy2dvzv.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1381355376 26547 80.91.229.3 (9 Oct 2013 21:49:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Oct 2013 21:49:36 +0000 (UTC) Cc: "guile-user@gnu.org" To: Dmitry Bogatov Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Oct 09 23:49:41 2013 Return-path: Envelope-to: guile-user@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 1VU1dV-0004oq-3U for guile-user@m.gmane.org; Wed, 09 Oct 2013 23:49:41 +0200 Original-Received: from localhost ([::1]:44046 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU1dU-0003Zv-QT for guile-user@m.gmane.org; Wed, 09 Oct 2013 17:49:40 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU1dI-0003Yw-MP for guile-user@gnu.org; Wed, 09 Oct 2013 17:49:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VU1dE-0006pA-Ox for guile-user@gnu.org; Wed, 09 Oct 2013 17:49:28 -0400 Original-Received: from mail-we0-x22e.google.com ([2a00:1450:400c:c03::22e]:33193) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU1dE-0006oY-D5; Wed, 09 Oct 2013 17:49:24 -0400 Original-Received: by mail-we0-f174.google.com with SMTP id u56so1575390wes.33 for ; Wed, 09 Oct 2013 14:49:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:references:mail-followup-to:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=/AeXunEYC9zpTPkldMP1Hfzrg5Ny3WYDNaG0hCFdwK4=; b=wCDIS039Yvt4v8vFiAeNcXFXYACxBMj0VeLPGmvqjv+HfQlz3p2GAVeFBoFC+u5mab 1yO/2k2cQmgKJ+BPTXas+fCa1B1AYqHGzkTtnZQwBADMpnog2C1IhTp9/7ETEBuELVfR F0xkgmkOeSurgvJ78ymUjIxFzJYC3Pzd+Vdq4o58SszqBViRHoESmOVeDo5QZ8tQt/Vr pLXY7Tn9kAyWn8ADPfr2HG2Unk6vF6RwdklteCtSDMeZWTWO6pZT6VMlpEh/hG8Uizl6 tn9z6T24I6Bap7jgsmn0ScSwlWwXsokHgeqZ3Pi87/Gp1HudBvB18ax39CjtaMQ3Uf6Z Qkuw== X-Received: by 10.180.73.113 with SMTP id k17mr4642494wiv.6.1381355362824; Wed, 09 Oct 2013 14:49:22 -0700 (PDT) Original-Received: from Kagami.home (host86-132-92-201.range86-132.btcentralplus.com. [86.132.92.201]) by mx.google.com with ESMTPSA id e1sm19250066wij.6.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 09 Oct 2013 14:49:21 -0700 (PDT) Mail-Followup-To: Dmitry Bogatov , "guile-user\@gnu.org" In-Reply-To: <878uy2dvzv.fsf@gnu.org> (Dmitry Bogatov's message of "Thu, 10 Oct 2013 00:34:12 +0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22e X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:10842 Archived-At: --=-=-= Content-Type: text/plain Dmitry Bogatov writes: > Documentation for vectors says: > Like lists, vectors have to be quoted: Which is wrong, vectors are self quoting. > Altho: > (define foo #((+ 1 2) 2)) > (eq? foo (eval foo (current-module))) ;; #t And that is a weird example you've chosen, as I don't expect eval to eval a vector, I'd have just printed it. > Am I missing something, or documentation is not in sync with current > state of art? The latter, though there is no penalty (performance or stylistic) if you are quoting your vectors. I've done a git grep though the docs, and there are a few referenes to it in texi files. - r5rs.texi should _not_ be change, since r5rs says vectors must be quoted. - guile.texi is autogenerated - api-evaluation.texi has an example in the section on quoting - api-compound.texi The last one is the only one that needs to be changed IMO. Most of the other references are in code or tests where they do no harm, but I'm not sure about vectors.c. There it appears in comments (which might be snarfed into guile.texi?) and one uncommented docstring. Is it worth changing? Patch attached that changes api-compound.texi. I split the paragraph to make it easier. -- Ian Price -- shift-reset.com "Programming is like pinball. The reward for doing it well is the opportunity to do it again" - from "The Wizardy Compiled" --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Doc-mention-vectors-are-self-quoting.patch Content-Description: self quoting fix >From ddda4d53e588441e15b39c36033ed7f425fa3895 Mon Sep 17 00:00:00 2001 From: Ian Price Date: Wed, 9 Oct 2013 22:48:16 +0100 Subject: [PATCH] Doc: mention vectors are self-quoting Reported by Dmitry Bogatov . * doc/ref/api-compound.texi (Vector Syntax, Vector Creation): Mention that vectors are self-quoting. Remove examples with quote signs. --- doc/ref/api-compound.texi | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/doc/ref/api-compound.texi b/doc/ref/api-compound.texi index 1990d77..94e0145 100644 --- a/doc/ref/api-compound.texi +++ b/doc/ref/api-compound.texi @@ -689,22 +689,18 @@ Vectors can literally be entered in source code, just like strings, characters or some of the other data types. The read syntax for vectors is as follows: A sharp sign (@code{#}), followed by an opening parentheses, all elements of the vector in their respective read syntax, -and finally a closing parentheses. The following are examples of the -read syntax for vectors; where the first vector only contains numbers -and the second three different object types: a string, a symbol and a -number in hexadecimal notation. +and finally a closing parentheses. Like strings, vectors do not have to +be quoted. + +The following are examples of the read syntax for vectors; where the +first vector only contains numbers and the second three different object +types: a string, a symbol and a number in hexadecimal notation. @lisp #(1 2 3) #("Hello" foo #xdeadbeef) @end lisp -Like lists, vectors have to be quoted: - -@lisp -'#(a b c) @result{} #(a b c) -@end lisp - @node Vector Creation @subsubsection Dynamic Vector Creation and Validation @@ -735,7 +731,7 @@ The inverse operation is @code{vector->list}: Return a newly allocated list composed of the elements of @var{v}. @lisp -(vector->list '#(dah dah didah)) @result{} (dah dah didah) +(vector->list #(dah dah didah)) @result{} (dah dah didah) (list->vector '(dididit dah)) @result{} #(dididit dah) @end lisp @end deffn @@ -796,8 +792,8 @@ Return the number of elements in @var{vec} as a @code{size_t}. Return the contents of position @var{k} of @var{vec}. @var{k} must be a valid index of @var{vec}. @lisp -(vector-ref '#(1 1 2 3 5 8 13 21) 5) @result{} 8 -(vector-ref '#(1 1 2 3 5 8 13 21) +(vector-ref #(1 1 2 3 5 8 13 21) 5) @result{} 8 +(vector-ref #(1 1 2 3 5 8 13 21) (let ((i (round (* 2 (acos -1))))) (if (inexact? i) (inexact->exact i) -- 1.7.11.7 --=-=-=--