help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: why are there [v e c t o r s] in Lisp?


From: Emanuel Berg
Subject: Re: why are there [v e c t o r s] in Lisp?
Date: Fri, 16 Oct 2015 04:31:40 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

"Pascal J. Bourguignon" <pjb@informatimago.com>
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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]