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: Re: why are there [v e c t o r s] in Lisp? Date: Fri, 16 Oct 2015 04:31:40 +0200 Message-ID: <87io67pmr7.fsf@debian.uxu> References: <87mvvjeg29.fsf@kuiper.lan.informatimago.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1444962184 21648 80.91.229.3 (16 Oct 2015 02:23:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 16 Oct 2015 02:23:04 +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 Oct 16 04:22:55 2015 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 1ZmufX-0002fd-83 for geh-help-gnu-emacs@m.gmane.org; Fri, 16 Oct 2015 04:22:55 +0200 Original-Received: from localhost ([::1]:50485 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmufW-0002Kw-A7 for geh-help-gnu-emacs@m.gmane.org; Thu, 15 Oct 2015 22:22:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmufL-0002Kr-A5 for help-gnu-emacs@gnu.org; Thu, 15 Oct 2015 22:22:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZmufG-00048D-Bg for help-gnu-emacs@gnu.org; Thu, 15 Oct 2015 22:22:43 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:50364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmufG-000487-4T for help-gnu-emacs@gnu.org; Thu, 15 Oct 2015 22:22:38 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZmufD-0002IS-2F for help-gnu-emacs@gnu.org; Fri, 16 Oct 2015 04:22:35 +0200 Original-Received: from nl106-137-244.student.uu.se ([130.243.137.244]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Oct 2015 04:22:35 +0200 Original-Received: from embe8573 by nl106-137-244.student.uu.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 16 Oct 2015 04:22:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Original-Lines: 76 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: nl106-137-244.student.uu.se Mail-Copies-To: never User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:7EYj2IqZT2c79a+B9TZv0EAgqSM= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:107666 Archived-At: "Pascal J. Bourguignon" writes: >> Why is there a special syntax for vectors? > > To make it easy to introduce literal vectors in > your programs. OK, if you do it all day long that is an advantage just as I wouldn't want to do strings as lists, not that I use that much strings - however there is a flaw to the analogy and that is: having a string instead as a list isn't nearly as readable or editable as is a string - compare (print "message") (print '(m e s s a g e)) while I don't see any such difference with [1 2 3] and '(1 2 3)! Perhaps if you did a special syntax highlight for the squared vectors that would make them more visible and easily detected along with all the other parenthesised code - again, only if you have tons of vectors this would make for any practical difference. (It might look cool tho.) > Without this syntax, you would only have run-time > constructors, and you would have to write more > complex code. ... why? If lists are vectors, which they are in terms of what they hold and how they look, then you don't need more code compared to vectors, on the contrary you need less code! > For example, the equivalent of: > > (defun permut-0213 (x) > (aref [0 2 1 3] x)) > > would have to be written as: > > (defun permut-0213 (x) > (aref (load-time-value (vector 0 2 1 3)) x)) What I mean is, the list '(0 2 1 3) is already a vector, why not just leave it at that? > Therefore a list such as (1 2 3 4 5) will be > actually a cons cell: (1 . (2 . (3 . (4 . (5 . > nil))))) Indeed, but the same argument as I just made for strings can be applied here as well: 1) Strings and lists are so common so they should look their best, which is why we can't have strings lists or lists cons cells, because then they don't even look like what they are. 2) Vectors are not that common, but just because something is less common doesn't mean it should be treated worse, fine - still, '(1 2 3) doesn't look any worse than [1 2 3] - even in math books the square brackets are sometimes not square, but parenthesis (denoting lists, ordered n-paris, or vectors!). The rest of the post I appreciate and especially the the ASCII figures. -- underground experts united http://user.it.uu.se/~embe8573