unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* _writable_elements & empty vectors
@ 2017-09-11 11:57 Daniel Llorens
  2017-09-14 21:35 ` Mark H Weaver
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Llorens @ 2017-09-11 11:57 UTC (permalink / raw)
  To: guile-devel


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.

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

Regards

	Daniel


PS Please also review/ack the patchset at wip-exception-truncate, except for the last patch which is a temporary hack (http://git.savannah.gnu.org/gitweb/?p=guile.git;a=shortlog;h=refs/heads/wip-exception-truncate).

I've already submitted this patchset to the list in the format-patch style, actually I've submitted it twice (second time https://lists.gnu.org/archive/html/guile-devel/2017-02/msg00046.html), but I can do it again, if it helps. I've rebased the patchset on top of stable-2.2 and I've also updated it to fix the bug in (sort!) by checking argument sizes. 





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: _writable_elements & empty vectors
  2017-09-11 11:57 _writable_elements & empty vectors Daniel Llorens
@ 2017-09-14 21:35 ` Mark H Weaver
  0 siblings, 0 replies; 2+ messages in thread
From: Mark H Weaver @ 2017-09-14 21:35 UTC (permalink / raw)
  To: Daniel Llorens; +Cc: guile-devel

Daniel Llorens <daniel.llorens@bluewin.ch> 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!

      Mark



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-14 21:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-11 11:57 _writable_elements & empty vectors Daniel Llorens
2017-09-14 21:35 ` Mark H Weaver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).