unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: divoplade <d@divoplade.fr>
To: Guile User <guile-user@gnu.org>
Subject: What is the point of bytevectors?
Date: Sat, 12 Sep 2020 09:49:53 +0200	[thread overview]
Message-ID: <663bcc3f7ca042bfd727cbcecb0dccfcde43aec8.camel@divoplade.fr> (raw)

Hello guile users,

I am writing a library mixing some scheme code and C code, and I have
two options for interfacing C strings:
1. Use bytevectors;
2. Use strings with byte access semantics (so-called latin-1, which is
really a misleading name since it will most certainly contain utf-8-
encoded unicode text).

From the C side, they have nearly identical APIs, and the conversion
functions do not transcode anything.

From the scheme side, however:
1. The bytevector library needs to be imported;
2. The function names have way more characters to type;
3. The bytevector library is missing a lot of text functions (like
join, split, trim, pad, searching...).

If the user wants to always manipulate unicode (decoded) strings, using
either bytevectors or latin-1 strings require transcoding to enter the
library and to exit the library, so either option is valid.

But if the user wants to always manipulate utf-8-encoded strings [1],
using bytevectors is impossible or much more difficult (see points
above).

So, why should I ever use bytevectors?

divoplade

[1] https://utf8everywhere.org/




             reply	other threads:[~2020-09-12  7:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12  7:49 divoplade [this message]
2020-09-12 10:35 ` What is the point of bytevectors? Linus Björnstam
2020-09-12 16:48 ` John Cowan
2020-09-12 17:14   ` divoplade
2020-09-12 17:24     ` John Cowan

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=663bcc3f7ca042bfd727cbcecb0dccfcde43aec8.camel@divoplade.fr \
    --to=d@divoplade.fr \
    --cc=guile-user@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).