unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Marius Vollmer <mvo@zagadka.de>
Cc: Paul Jarc <prj@po.cwru.edu>, guile-devel@gnu.org
Subject: Re: GH replacement proposal (includes a bit of Unicode)
Date: Thu, 03 Jun 2004 23:40:03 +0200	[thread overview]
Message-ID: <87smdcqq18.fsf@zagadka.ping.de> (raw)
In-Reply-To: <40B50BA8.2050604@dirk-herrmanns-seiten.de> (Dirk Herrmann's message of "Wed, 26 May 2004 23:27:04 +0200")

Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> writes:

> Marius Vollmer wrote:
>
>>  Dirk Herrmann <dirk@dirk-herrmanns-seiten.de> 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?

The way it is worded in the proposal right now, -2 would be
interpreted as an unsigned value, that is, as a very large length.  In
other words, only one value, ((size_t)-1), is interpreted specially.

> You are trying to explain why the -1 idiom is not too bad.

I'm arguing that it is well known, not that it is necessarily good or
better.  Also, I really do think that people expect to be able to pass
-1 as the length parameter, as a convenience feature.

One point of the proposal is to make the API very easy to use, where
the 'obvious' way to use it is also the correct one.

So, IMO, we need to interpret -1 specially.  The question is then, is
it an advantage to have an additional way to have Guile count the
string length on its own?

> But, why do you think it is better?

I think it is good enough, but I'm of course listening to your
arguments.

>>  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.

Noted.

> 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.

Yeah, I'm convinced.

> 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);

I would not like to use the "memory" term to indicate a string that is
not zero terminated; "memory" is too generic.  Also, "0string" feels
not right either, since it makes it look as if a 0string would
be something very special although it is the ordinary thing (for C).

What about

   SCM scm_from_locale_string (unsigned char *str);
   SCM scm_from_locale_string_counted (unsigned char *str, size_t len);

'scm_from_locale_string_counted' would treat len == -1 specially.

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel


  reply	other threads:[~2004-06-03 21:40 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-07 13:00 GH replacement proposal (includes a bit of Unicode) Marius Vollmer
2004-04-07 15:04 ` Paul Jarc
2004-04-13 13:25   ` Marius Vollmer
2004-04-13 15:54     ` Paul Jarc
2004-04-21 15:08       ` Marius Vollmer
2004-04-21 16:10         ` Paul Jarc
2004-04-21 18:06           ` Marius Vollmer
2004-04-21 16:31         ` Delivery failure (guile-devel@gnu.org) Bruce Korb
2004-04-21 21:34           ` GH replacement proposal (includes a bit of Unicode) Marius Vollmer
2004-04-21 21:46             ` Paul Jarc
2004-04-21 22:19               ` Dale P. Smith
2004-04-21 22:34                 ` Paul Jarc
2004-04-21 23:02                 ` Kevin Ryde
2004-04-22 17:36             ` Dirk Herrmann
2004-04-22 18:31               ` Paul Jarc
2004-05-17 21:14                 ` Marius Vollmer
2004-05-17 21:57                   ` Bruce Korb
2004-05-18  9:54                     ` Marius Vollmer
2004-04-22 17:00         ` Dirk Herrmann
2004-04-24 10:06         ` Dirk Herrmann
2004-04-24 19:46           ` Marius Vollmer
2004-04-25 20:33             ` Dirk Herrmann
2004-04-25 21:38             ` Paul Jarc
2004-05-17 21:45               ` Marius Vollmer
2004-04-17 13:21 ` Dirk Herrmann
2004-04-22  4:16   ` Rob Browning
2004-04-22 17:48     ` Dirk Herrmann
2004-05-12 20:09   ` Marius Vollmer
2004-05-15  9:50     ` Dirk Herrmann
2004-05-24 18:51       ` Marius Vollmer
2004-05-25  0:21         ` Paul Jarc
2004-05-26 21:27         ` Dirk Herrmann
2004-06-03 21:40           ` Marius Vollmer [this message]
2004-06-04  6:52             ` tomas
2004-08-09 22:29               ` Marius Vollmer
2004-05-15 10:18     ` Dirk Herrmann
2004-05-24 19:36       ` Marius Vollmer
2004-05-26 22:11         ` Dirk Herrmann
2004-08-09 22:28           ` Marius Vollmer
2004-04-22  4:39 ` Rob Browning
2004-04-22 17:58   ` Dirk Herrmann
2004-04-23  0:25     ` Rob Browning
2004-04-23 16:57   ` Marius Vollmer
2004-04-23 17:16     ` Rob Browning
2004-05-17 21:24       ` Marius Vollmer
2004-04-23 17:36     ` Andreas Rottmann
2004-05-17 21:30       ` Marius Vollmer
2004-05-18  9:21         ` Andreas Rottmann
2004-04-25  7:54     ` Dirk Herrmann
2004-05-17 21:44       ` Marius Vollmer

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=87smdcqq18.fsf@zagadka.ping.de \
    --to=mvo@zagadka.de \
    --cc=guile-devel@gnu.org \
    --cc=prj@po.cwru.edu \
    /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).