unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Dirk Herrmann <dirk@dirk-herrmanns-seiten.de>
Cc: guile-devel@gnu.org
Subject: Re: GH replacement proposal (includes a bit of Unicode)
Date: Thu, 27 May 2004 00:11:37 +0200	[thread overview]
Message-ID: <40B51619.3010505@dirk-herrmanns-seiten.de> (raw)
In-Reply-To: <87ekp962jc.fsf@zagadka.ping.de>

Marius Vollmer wrote:

>  Hmm, there might be a misunderstanding somewhere: they way I want it,
>  scm_to_int would either produce a correctly converted 'int', or
>  would signal an error. The error might be a 'wrong type argument'
>  one when a non-integer has been passed to scm_to_int, or it might be
>  a 'argument out of range' one, when the integer doesn't fit into an
>  'int'. There would not be the case that code would silently work
>  with incorrect values.

No misunderstanding. I fully agree with you that the code should never
silently work with incorrect values. However, if scm_to_int throws an
error 'wrong type argument' or 'argument out of range', this is still not
too much of a help in many cases.

>  I see the typical use of scm_to_int etc to be in glue code, like
>
>  SCM posix_kill (SCM pid, SCM sig) { return scm_from_int (kill
>  (scm_to_int (pid), scm_to_int (sig))); }
>
>  That is all it should take to wrap 'kill'.

And it is already an example that 'argument out of range' is not a
very good message if the return value is out of range. But, this can
certainly easily be fixed by changing the error message to 'value out
of range'.

Still, I am wondering whether a user of this function would not be
happier if instead of 'argument out of range' or 'value out of range'
the message would be one of
  'process id argument to kill out of range'
  'signal argument to kill out of range'
and if you are not really sure what posix_kill returns
  'return value of system function kill out of range'.


Looking again at the solution that I had suggested:
  <type> scm_to_<type> (SCM value, int *success)
might even be extended: Instead of returning just true or false
for success, the following, more fine-grained results could be
given:
  typedef enum {
    SCM_TO_INTEGER_OK,
    SCM_TO_INTEGER_UNDERFLOW,
    SCM_TO_INTEGER_OVERFLOW
  } scm_t_scm_to_integer_conversion_state;
Depending on the way the scm_to_<type> functions for
integer types would be implemented, this could be provided
at almost no cost. It might be helpful for code that decides
to fall back to the minimum/maximum value in case of an
underflow/overflow.

(This is yet another design alternative.)


But, all in all I could live with the decision to have the range-
checking functions separate.

On what basis would the decision be taken? By asking people
on the guile-devel and guile-user lists what they would prefer?
This would give us a better indication of what the typical case
really is. Everything else is just guessing and taking decisions
on a maybe unsufficient knowledge base.

Best regards,
Dirk



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


  reply	other threads:[~2004-05-26 22:11 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
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 [this message]
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=40B51619.3010505@dirk-herrmanns-seiten.de \
    --to=dirk@dirk-herrmanns-seiten.de \
    --cc=guile-devel@gnu.org \
    /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).