public inbox for guile-gtk@sourceware.org
 help / color / mirror / Atom feed
* GError
@ 2003-05-24 11:49 Andy Wingo
  2003-05-25 23:16 ` GError Kevin Ryde
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Wingo @ 2003-05-24 11:49 UTC (permalink / raw)
  To: guile-gtk

Hi Andreas and Kevin,

Sorry I can't reply directly to the earlier emails, I was on holiday and
not on the list at that point.

I'd first like to thank you all for the interest in the GTK2 branch of
things, especially as expressed by code. That's great! More about that
in my next email.

With regards to GError, I think the solution you propose is too much
like C programming. Wouldn't it be nicer if, instead of forcing the
programmer to know about GErrors, if we simply threw an exception if the
GError is set? That would seem to me to be the more sensible
alternative. We can make the load-defs code recognize the presence of a
GError in the last argument position (as it always is) and then... Hmm,
it's a bit of a PITA in that the desired scheme function has fewer
arguments than the C function. I think that to support this fully, we
would have to extend g-wrap. What do you think about this idea?

And along the extending-g-wrap lines, I sent a mail to Rob Browning
asking him to accept the newer gw-standard-spec.scm into the distro, but
have not received a reply as of yet. Perhaps we need to try a bit
harder.

Anyway, do let me know what you think about all of this.

regards,

wingo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GError
  2003-05-24 11:49 GError Andy Wingo
@ 2003-05-25 23:16 ` Kevin Ryde
  2003-06-02  6:51   ` GError Andy Wingo
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2003-05-25 23:16 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guile-gtk

Andy Wingo <wingo@pobox.com> writes:
>
> With regards to GError, I think the solution you propose is too much
> like C programming.

Oh, well, if it's nice and close then at least people familiar with
the C style will find the guile interface comfortingly similar.  Or
vice versa even.

> Wouldn't it be nicer if, instead of forcing the
> programmer to know about GErrors, if we simply threw an exception if the
> GError is set?

Perhaps make the gerror parameter optional, if omitted an error is
thrown.  Or a special value 'error or something to mean that.

That could allow a choice between programming in typical glib style
(check return values) or more typical guile style (file i/o throws
exceptions).

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GError
  2003-05-25 23:16 ` GError Kevin Ryde
@ 2003-06-02  6:51   ` Andy Wingo
  2003-06-02  9:20     ` GError Andreas Rottmann
  2003-06-06 22:59     ` GError Kevin Ryde
  0 siblings, 2 replies; 6+ messages in thread
From: Andy Wingo @ 2003-06-02  6:51 UTC (permalink / raw)
  To: guile-gtk

Hi Kevin,

On Mon, 26 May 2003, Kevin Ryde wrote:

> Andy Wingo <wingo@pobox.com> writes:
> >
> > With regards to GError, I think the solution you propose is too much
> > like C programming.
> 
> Oh, well, if it's nice and close then at least people familiar with
> the C style will find the guile interface comfortingly similar.  Or
> vice versa even.

I'm not sure that an identical function mapping is really a goal. I am
programming in scheme because I prefer it to C. In making these
bindings, the goal has been to make the functionality of the gnome APIs
available from scheme, not strict API transliteration. I don't think
throwing exceptions will bother anyone who chooses scheme over C.

A quick search through gnome/defs shows the following occurences of GError:

 * Gdk: 7 uses, all regarding file i/o (pixbuf loading and saving,
   mostly)
 * Pango: 1 use, pango_parse_markup
 * GConf: a boatload of uses, for a boatload of reasons: permissions,
   client-server communication, etc etc
 * applets: 1 use, setting something gconf-related
 * libgnome: 4 uses, regarding failure to display help or uris
 * glib: only appears in g_error_*

These are the sorts of things exceptions are made for. Furthermore,
exposing GError to the programmer leads to nastiness on the scheme side
of things.

You could implement exceptions by adding 'c-only to the typespec and
extending g-wrap to ignore, from the scheme side, parameters with
'c-only in their typespecs. The scm->c and c->scm ccodegens would still
be run, however, allowing the error to be initialized and checked.

regards,

wingo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GError
  2003-06-02  6:51   ` GError Andy Wingo
@ 2003-06-02  9:20     ` Andreas Rottmann
  2003-06-06 22:59     ` GError Kevin Ryde
  1 sibling, 0 replies; 6+ messages in thread
From: Andreas Rottmann @ 2003-06-02  9:20 UTC (permalink / raw)
  To: guile-gtk

Andy Wingo <wingo@pobox.com> writes:

> Hi Kevin,
>
> On Mon, 26 May 2003, Kevin Ryde wrote:
>
>> Andy Wingo <wingo@pobox.com> writes:
>> >
>> > With regards to GError, I think the solution you propose is too much
>> > like C programming.
>> 
>> Oh, well, if it's nice and close then at least people familiar with
>> the C style will find the guile interface comfortingly similar.  Or
>> vice versa even.
>
> I'm not sure that an identical function mapping is really a goal. I am
> programming in scheme because I prefer it to C. In making these
> bindings, the goal has been to make the functionality of the gnome APIs
> available from scheme, not strict API transliteration. I don't think
> throwing exceptions will bother anyone who chooses scheme over C.
>
> A quick search through gnome/defs shows the following occurences of GError:
>
>  * Gdk: 7 uses, all regarding file i/o (pixbuf loading and saving,
>    mostly)
>  * Pango: 1 use, pango_parse_markup
>  * GConf: a boatload of uses, for a boatload of reasons: permissions,
>    client-server communication, etc etc
>  * applets: 1 use, setting something gconf-related
>  * libgnome: 4 uses, regarding failure to display help or uris
>  * glib: only appears in g_error_*
     ^^^^^^^
Not really true; there are quite a bunch of uses in glib:

~% grep GError /usr/include/glib-2.0/glib/*.h | wc -l
     68

> These are the sorts of things exceptions are made for. Furthermore,
> exposing GError to the programmer leads to nastiness on the scheme side
> of things.
>
> You could implement exceptions by adding 'c-only to the typespec and
> extending g-wrap to ignore, from the scheme side, parameters with
> 'c-only in their typespecs. The scm->c and c->scm ccodegens would still
> be run, however, allowing the error to be initialized and checked.
>
I agree that throwing exceptions instead of using GError is probably
the way to go; especially if you take this into account (from the GLib
manual):

,----
| GLib provides a standard method of reporting errors from a called
| function to the calling code. (This is the same problem solved by
| exceptions in other languages.)
`----

Regards, Andy
-- 
Andreas Rottmann         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

It's GNU/Linux dammit!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GError
  2003-06-02  6:51   ` GError Andy Wingo
  2003-06-02  9:20     ` GError Andreas Rottmann
@ 2003-06-06 22:59     ` Kevin Ryde
  2003-07-22 14:22       ` GError Andy Wingo
  1 sibling, 1 reply; 6+ messages in thread
From: Kevin Ryde @ 2003-06-06 22:59 UTC (permalink / raw)
  To: guile-gtk

Andy Wingo <wingo@pobox.com> writes:
>
> A quick search through gnome/defs shows the following occurences of GError:

You might be right, not many look terribly interesting things to
continue normal operations after.

If GError is uniformly the last parameter to the functions then if
initially omitted from the scheme procedures it could always be added
back later.

Or plan to accept only #f there for now, meaning disable the exception
throw.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: GError
  2003-06-06 22:59     ` GError Kevin Ryde
@ 2003-07-22 14:22       ` Andy Wingo
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Wingo @ 2003-07-22 14:22 UTC (permalink / raw)
  To: guile-gtk

Hey y'all, I'm on African time!

On Sat, 07 Jun 2003, Kevin Ryde wrote:

> Andy Wingo <wingo@pobox.com> writes:
> >
> > A quick search through gnome/defs shows the following occurences of GError:
(my glib count only counted the parts that I was wrapping ;)

> Or plan to accept only #f there for now, meaning disable the exception
> throw.

That's the current situation, although some functions might be still
missing (null-ok).

I would hold off on working on this until Rob Browning wakes up from the
dead and does something with g-wrap, because it requires upstream
changes to g-wrap.

Regards,

wingo.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2003-07-22 14:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-24 11:49 GError Andy Wingo
2003-05-25 23:16 ` GError Kevin Ryde
2003-06-02  6:51   ` GError Andy Wingo
2003-06-02  9:20     ` GError Andreas Rottmann
2003-06-06 22:59     ` GError Kevin Ryde
2003-07-22 14:22       ` GError Andy Wingo

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