[Top][All Lists]

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

Re: _writable_elements & empty vectors

From: Mark H Weaver
Subject: Re: _writable_elements & empty vectors
Date: Thu, 14 Sep 2017 17:35:58 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Daniel Llorens <address@hidden> writes:

> There is a whole set of functions scm_TYPE_writable_elements in
> Guile. In 2.2 these functions must be called with mutable containers.
> The problem is that empty vectors or arrays are immutable, so one is
> forced to guard every call to scm_TYPE_writable_elements with a
> superfluous size check.
> E.g.
> (vector 1 2) -> new mutable vector
> (vector 1) -> new mutable vector
> (vector) -> const non-mutable vector
> This causes (sort! (vector) <) to fail in Guile 2.2.
> I think scm_TYPE_writable_elements should accept empty vectors whether
> they're technically mutable or not, and return NULL.

I agree.  Even from a strictly logical standpoint, if we define
"scm_TYPE_writable_elements" to mean "forall elements X in the object, X
is mutable", then that statement is certainly true if there are no
elements in the object.

> Let me know if you disagree, otherwise I'll submit a patch. 

Sounds good, thanks!


reply via email to

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