From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Dirk Herrmann Newsgroups: gmane.lisp.guile.devel Subject: Re: GH replacement proposal (includes a bit of Unicode) Date: Wed, 26 May 2004 23:27:04 +0200 Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Message-ID: <40B50BA8.2050604@dirk-herrmanns-seiten.de> References: <40812F4B.3080700@dirk-herrmanns-seiten.de> <873c65be76.fsf@zagadka.ping.de> <40A5E7C8.9080409@dirk-herrmanns-seiten.de> <87isel64mf.fsf@zagadka.ping.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1085608229 27837 80.91.224.253 (26 May 2004 21:50:29 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 26 May 2004 21:50:29 +0000 (UTC) Cc: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed May 26 23:50:21 2004 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BT6I1-0006Wq-00 for ; Wed, 26 May 2004 23:50:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BT64u-0005Zd-9B for guile-devel@m.gmane.org; Wed, 26 May 2004 17:36:48 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.34) id 1BT62m-00054v-5E for guile-devel@gnu.org; Wed, 26 May 2004 17:34:36 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.34) id 1BT627-0004sA-PP for guile-devel@gnu.org; Wed, 26 May 2004 17:34:27 -0400 Original-Received: from [212.227.126.189] (helo=moutng.kundenserver.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BT5Ve-0006x6-HU for guile-devel@gnu.org; Wed, 26 May 2004 17:00:23 -0400 Original-Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1BT5Vb-0000E7-00; Wed, 26 May 2004 23:00:19 +0200 Original-Received: from [80.131.47.119] (helo=dirk-herrmanns-seiten.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1BT5Va-00083r-00; Wed, 26 May 2004 23:00:18 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040220 X-Accept-Language: de, en Original-To: Marius Vollmer , Paul Jarc In-Reply-To: <87isel64mf.fsf@zagadka.ping.de> X-Enigmail-Version: 0.76.8.0 X-Enigmail-Supports: pgp-inline, pgp-mime X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:494e3e4d1bf8dc247959c49e6f1f4215 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.4 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 Xref: main.gmane.org gmane.lisp.guile.devel:3761 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:3761 Marius Vollmer wrote: > Dirk Herrmann writes: > > > Marius Vollmer wrote: > > > >> Hmm, yes, that might make sense. However, the -1 idiom is pretty > >> much standard for this kind of interface, no? > > > > I personally don't like this kind of 'one value, several meanings' > > paradigm: > > > > - What, if instead of -1, you pass -2? [...] - Readability suffers. > > [...] > > Yes, I agree that the -1 idiom is not self explaining, but it is well > established and people will instantly recognize it. I'd even argue > What about the -2 and so on? You are trying to explain why the -1 idiom is not too bad. But, why do you think it is better? Do you want to save an identifier? This can't really be the reason. Especially when looking at Paul's suggestion to introduce a macro scm_from_locale_0string, which also introduces a new identifier (and, Paul, I like your name better than my suggestion). > established and people will instantly recognize it. I'd even argue > that they will expect to be able to pass -1 for a 'len' parameter and > will be annoyed when they find out that Guile doesn't allow it. That's a guess. Maybe you should ask the people what they would prefer? Considering me as part of them, I would not prefer having the -1 idiom. > > SCM s = scm_from_locale_memory (str, len); > > This can be had with scm_from_locale_string as well, of course. When > you write > > SCM s = scm_from_locale_string (str, len); > > thats just as readable, I'd say. I agree that the function name scm_from_local_string when called with arguments str and len is not less readable (even better, I would say) than scm_from_locale_memory when called with arguments str and len. My point, however, was rather in the direction of saying that if the len argument is required since the application really knows the length, then passing it will always be readable. This is in contrast to passing the magic number -1 if the application does not know the length. However, I think you oversimplify my concerns if you only boild it down to the readability issue. There is also the aspect of type checking support by the compiler, the fact that code that works mostly with 0strings always has to pass an unnecessary parameter, the fact that the scm_from_locale_string function always has to handle the special -1 case, and probably more. Summarized, I would just claim that it is not a good API design, since I have not yet seen a convincing argument in favor of it. Considering your and Paul's answer, I would like to change my suggestion to the following pair of functions: SCM scm_from_locale_string (const unsigned char *str, size_t len); SCM scm_from_locale_0string (const unsigned char *str); Best regards, Dirk _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel