From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Bruce Korb Newsgroups: gmane.lisp.guile.devel Subject: Re: mutable interfaces - was: Guile: What's wrong with this? Date: Sat, 07 Jan 2012 09:35:14 -0800 Message-ID: <4F088252.9040000@gnu.org> References: <4F027F35.5020001@gmail.com> <1325603029.22166.YahooMailNeo@web37906.mail.mud.yahoo.com> <4F032C41.3070300@gmail.com> <87mxa4ifux.fsf@gnu.org> <4F038BF4.1070200@gnu.org> <87obujzmmc.fsf@Kagami.home> <4F048972.5040803@gnu.org> <87lipnm8yx.fsf@Kagami.home> <4F04D01D.5050801@gnu.org> <8762grf28k.fsf@netris.org> <4F05DC47.1000202@gnu.org> <878vlldb4k.fsf@netris.org> <1325811764.22562.YahooMailNeo@web37903.mail.mud.yahoo.com> <87wr95bo9y.fsf@netris.org> <1325857075.77324.YahooMailNeo@web37903.mail.mud.yahoo.com> <877h14bsx0.fsf@netris.org> <4F074647.1020000@gnu.org> <87ty478p9f.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1325957727 5205 80.91.229.12 (7 Jan 2012 17:35:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 7 Jan 2012 17:35:27 +0000 (UTC) Cc: guile-devel@gnu.org To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jan 07 18:35:23 2012 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RjaAt-0007T9-2Q for guile-devel@m.gmane.org; Sat, 07 Jan 2012 18:35:23 +0100 Original-Received: from localhost ([::1]:47341 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjaAs-0000aW-Hj for guile-devel@m.gmane.org; Sat, 07 Jan 2012 12:35:22 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:54618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjaAo-0000U1-OC for guile-devel@gnu.org; Sat, 07 Jan 2012 12:35:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RjaAn-0006yn-GV for guile-devel@gnu.org; Sat, 07 Jan 2012 12:35:18 -0500 Original-Received: from fencepost.gnu.org ([140.186.70.10]:43776) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RjaAn-0006yT-CQ for guile-devel@gnu.org; Sat, 07 Jan 2012 12:35:17 -0500 Original-Received: from adsl-75-0-186-252.dsl.pltn13.sbcglobal.net ([75.0.186.252]:56833 helo=[10.0.0.2]) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1RjaAn-0007I2-3p; Sat, 07 Jan 2012 12:35:17 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 In-Reply-To: <87ty478p9f.fsf@netris.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.10 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:13409 Archived-At: 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