unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Fwd: What is the point of bytevectors?
       [not found]   ` <CAGua6m2HFudH09LMV1JsWTWGeVDOR89w4M9MmYrtz-arXpQucA@mail.gmail.com>
@ 2020-09-12 16:31     ` Stefan Israelsson Tampe
  0 siblings, 0 replies; only message in thread
From: Stefan Israelsson Tampe @ 2020-09-12 16:31 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 2707 bytes --]

---------- Forwarded message ---------
From: Stefan Israelsson Tampe <stefan.itampe@gmail.com>
Date: Sat, Sep 12, 2020 at 5:12 PM
Subject: Re: What is the point of bytevectors?
To: Linus Björnstam <linus.internet@fastmail.se>


If you want to handle e.g. raw data bytevectors is a must. You will find
that you need it when working with binary files, interact with C etc etc.
Not so much managing strings, for that as you say the string object should
be enough. And now to a shamfule advertisement of my python module for
guile. In python bytevectors are very much like strings and you can usa all
the python ordinary string operations on it. You may even use the regular
expression module for it if you like. I have a schemish interface for it
and you may use that if you can stand the dependency.

On Sat, Sep 12, 2020 at 12:36 PM Linus Björnstam <linus.internet@fastmail.se>
wrote:

> The point is to work with binary data, of which the most common type of C
> strings are one kind.
>
> If you are using libguile in your C code you can use guile strings in your
> C code and pass them around to avoid the encoding/decoding overhead. Or,
> the other way around, expose the procedures that work with whatever C
> string representation your are using to guile.
>
> If your latin1 strings contain unicode data they are not latin1.
>
> --
>   Linus Björnstam
>
> On Sat, 12 Sep 2020, at 09:49, divoplade wrote:
> > 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/
> >
> >
> >
>
>

[-- Attachment #2: Type: text/html, Size: 3570 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-12 16:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <663bcc3f7ca042bfd727cbcecb0dccfcde43aec8.camel@divoplade.fr>
     [not found] ` <a5cbd840-4ff6-4269-a013-e94da8a6d2a1@www.fastmail.com>
     [not found]   ` <CAGua6m2HFudH09LMV1JsWTWGeVDOR89w4M9MmYrtz-arXpQucA@mail.gmail.com>
2020-09-12 16:31     ` Fwd: What is the point of bytevectors? Stefan Israelsson Tampe

unofficial mirror of guile-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guile-devel/0 guile-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guile-devel guile-devel/ https://yhetil.org/guile-devel \
		guile-devel@gnu.org
	public-inbox-index guile-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.lisp.guile.devel
	nntp://news.gmane.io/gmane.lisp.guile.devel


AGPL code for this site: git clone http://ou63pmih66umazou.onion/public-inbox.git