guile-devel
[Top][All Lists]
Advanced

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

Re: mutable interfaces - was: Guile: What's wrong with this?


From: Bruce Korb
Subject: Re: mutable interfaces - was: Guile: What's wrong with this?
Date: Sat, 07 Jan 2012 09:35:14 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0

On 01/07/12 08:13, Mark H Weaver wrote:
Most of the strings that I wind up altering are created with a
scm_from_locale_string() C function call.

BTW, beware that scm_from_locale_string() is only appropriate for
strings that came from the user (e.g. command-line arguments, reading
from a port, etc).  When converting string literals from your own source
code, you should use scm_from_latin1_string() or scm_from_utf8_string().

Similarly, to make symbols from C string literals, use
scm_from_latin1_symbol() or scm_from_utf8_symbol().

Caveat: these functions did not exist in Guile 1.8.  If your C string
literals are ASCII-only, I guess it won't matter in practice which
function you use, although it would be good to spread the understanding
that C string literals should not be interpreted according to the user's
locale.

I go back to my argument that a facilitation language needs to focus
on being as helpful as possible.  That means doing what is likely
wanted instead of throwing errors at every possibility.  It also means
not changing interfaces.  It is certainly much more stable now than
it was in the 1.4 to 1.6 transition era, but still.

Anyway, this then?  (abbreviated)

#if   GUILE_VERSION < 107000
# define AG_SCM_STR02SCM(_s)          scm_makfrom0str(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_mem2string(_st,_sz)

#elif   GUILE_VERSION < 200000
# define AG_SCM_STR02SCM(_s)          scm_from_locale_string(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_from_locale_stringn(_st,_sz)

#elif   GUILE_VERSION < 200004
#error "autogen does not work with this version of guile"
  choke me.

#else
# define AG_SCM_STR02SCM(_s)          scm_from_utf8_string(_s)
# define AG_SCM_STR2SCM(_st,_sz)      scm_from_utf8_stringn(_st,_sz)
#endif



reply via email to

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