emacs-devel
[Top][All Lists]
Advanced

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

Re: make-vector documentation is wrong


From: Stefan Monnier
Subject: Re: make-vector documentation is wrong
Date: Thu, 14 May 2020 23:41:52 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> (make-string 0 0), (make-list 0 0), (vector), and (list) all have the property
> that (make-vector 0 0) does - that is, each call returns the same empty object
> each time. I imagine that make-vector was implemented to be consistent with 
> the
> other functions - at least, this behavior appears to be a conscious decision
> rather than accidental. So it may make sense to change these functions'
> documentation instead of their implementation's longstanding behavior.

Actually, IIRC, for vectors it wasn't done "to make things consistent"
but because it simplified the memory management (IIRC the malloc-like
level needed its smallest object to be bigger than a 0-length vector,
so instead of adding an ad-hoc exception for 0-length vectors to
artificially use up more space, we decided to return a constant because
it was both simpler and more efficient).

I can't see any strong argument either for making sure (vector) returns
a fresh object nor for enforcing that it always returns the same object,
so I'd favor a documentation that says both things are valid
(i.e. Elisp code shouldn't rely on either behavior).


        Stefan




reply via email to

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