unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Daniel Llorens <daniel.llorens@bluewin.ch>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: _writable_elements & empty vectors
Date: Thu, 14 Sep 2017 17:35:58 -0400	[thread overview]
Message-ID: <87shfpyncx.fsf@netris.org> (raw)
In-Reply-To: <4F48E2ED-D196-48F1-A012-3364A9104555@bluewin.ch> (Daniel Llorens's message of "Mon, 11 Sep 2017 13:57:18 +0200")

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



      reply	other threads:[~2017-09-14 21:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-11 11:57 _writable_elements & empty vectors Daniel Llorens
2017-09-14 21:35 ` Mark H Weaver [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87shfpyncx.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=daniel.llorens@bluewin.ch \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).