unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* scm_make_gsubr question
@ 2003-01-19 20:40 William Morgan
  2003-01-19 23:55 ` Neil Jerram
  2003-01-21 15:04 ` Marius Vollmer
  0 siblings, 2 replies; 9+ messages in thread
From: William Morgan @ 2003-01-19 20:40 UTC (permalink / raw)


Dear Guile developers,

Is there a way to specify, at the time you call scm_make_gsubr, a user
data parameter which is passed to the corresponding C function? This
would allow the same C function to be used for multiple Guile
procedures, behaving differently based on the user data parameter.
(This is a standard mechanism in C callback-style libraries, e.g. glib.)

If not, I would like to submit a patch...

-- 
William <wmorgan@masanjin.net>


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


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

* Re: scm_make_gsubr question
  2003-01-19 20:40 scm_make_gsubr question William Morgan
@ 2003-01-19 23:55 ` Neil Jerram
  2003-01-20  8:24   ` Rob Browning
  2003-01-20  9:00   ` Mikael Djurfeldt
  2003-01-21 15:04 ` Marius Vollmer
  1 sibling, 2 replies; 9+ messages in thread
From: Neil Jerram @ 2003-01-19 23:55 UTC (permalink / raw)
  Cc: guile-devel

>>>>> "William" == William Morgan <wmorgan@masanjin.net> writes:

    William> Is there a way to specify, at the time you call
    William> scm_make_gsubr, a user data parameter which is passed to
    William> the corresponding C function? [...]

This has just been discussed on guile-user - please see the archives
there.  (Summary: (i) no (ii) you could use an applicable smob (iii)
description of a roundabout way of achieving the same thing.)

    William> If not, I would like to submit a patch...

Please do so; however, here is my view of why we don't already have
this (and which may amount to a good reason not to add it - I don't
know).

- The corresponding operation on the Scheme level is achieved much
  more elegantly by closure.

- There are ways of achieving this on the C level, even if they are a
  little indirect.  (See thread in guile-user.)

- The most sensible approach IMO for a Guile-based application is to
  do the minimum possible in C for the maximum benefit in Scheme.

Best regards,
        Neil



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


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

* Re: scm_make_gsubr question
  2003-01-19 23:55 ` Neil Jerram
@ 2003-01-20  8:24   ` Rob Browning
  2003-01-20  8:58     ` Marius Vollmer
  2003-01-20  9:00   ` Mikael Djurfeldt
  1 sibling, 1 reply; 9+ messages in thread
From: Rob Browning @ 2003-01-20  8:24 UTC (permalink / raw)
  Cc: guile-devel

Neil Jerram <neil@ossau.uklinux.net> writes:

> - The corresponding operation on the Scheme level is achieved much
>   more elegantly by closure.

[...]

> - The most sensible approach IMO for a Guile-based application is to
>   do the minimum possible in C for the maximum benefit in Scheme.

I tend to agree.  I wonder how often a user_data solution would be
better than restructuring the problem...

-- 
Rob Browning
rlb @defaultvalue.org, @linuxdevel.com, and @debian.org
Previously @cs.utexas.edu
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4


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


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

* Re: scm_make_gsubr question
  2003-01-20  8:24   ` Rob Browning
@ 2003-01-20  8:58     ` Marius Vollmer
  0 siblings, 0 replies; 9+ messages in thread
From: Marius Vollmer @ 2003-01-20  8:58 UTC (permalink / raw)
  Cc: Neil Jerram

Rob Browning <rlb@defaultvalue.org> writes:

> Neil Jerram <neil@ossau.uklinux.net> writes:
> 
> > - The corresponding operation on the Scheme level is achieved much
> >   more elegantly by closure.
> 
> [...]
> 
> > - The most sensible approach IMO for a Guile-based application is to
> >   do the minimum possible in C for the maximum benefit in Scheme.
> 
> I tend to agree.  I wonder how often a user_data solution would be
> better than restructuring the problem...

However, when his patch is nice and clean, we can have it both!  We do
already have 'compiled closures', but I think they are a bit
obscure...

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


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


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

* Re: scm_make_gsubr question
  2003-01-19 23:55 ` Neil Jerram
  2003-01-20  8:24   ` Rob Browning
@ 2003-01-20  9:00   ` Mikael Djurfeldt
  2003-01-20 19:07     ` William Morgan
  2003-02-02 22:55     ` Dale P. Smith
  1 sibling, 2 replies; 9+ messages in thread
From: Mikael Djurfeldt @ 2003-01-20  9:00 UTC (permalink / raw)
  Cc: guile-devel

Neil Jerram <neil@ossau.uklinux.net> writes:

>>>>>> "William" == William Morgan <wmorgan@masanjin.net> writes:
>
>     William> Is there a way to specify, at the time you call
>     William> scm_make_gsubr, a user data parameter which is passed to
>     William> the corresponding C function? [...]
>
> This has just been discussed on guile-user - please see the archives
> there.  (Summary: (i) no (ii) you could use an applicable smob (iii)
> description of a roundabout way of achieving the same thing.)
>
>     William> If not, I would like to submit a patch...
>
> Please do so; however, here is my view of why we don't already have
> this (and which may amount to a good reason not to add it - I don't
> know).

I don't think it's a good idea to add this to gsubrs.

We already have three different ways to do it:

1. applicable smobs

2. compiled closures (cclo)

3. entities and operators (applicable structs)

Of these, 1 and 2 are easy to do from C.

M


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


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

* Re: scm_make_gsubr question
  2003-01-20  9:00   ` Mikael Djurfeldt
@ 2003-01-20 19:07     ` William Morgan
  2003-01-20 20:03       ` Mikael Djurfeldt
  2003-02-02 22:55     ` Dale P. Smith
  1 sibling, 1 reply; 9+ messages in thread
From: William Morgan @ 2003-01-20 19:07 UTC (permalink / raw)


Excerpts (reformatted) from Mikael Djurfeldt's mail of 20 Jan 2003 (EST):
> I don't think it's a good idea to add this to gsubrs.

My question is partially mitigated by your reply below, but I think it's
worth considering who your target audience is:

If it includes C programmers who want to link Guile in as a scripting
language, possibly who are not very fluent in Scheme, and possibly (as
was the case on guile-user recently) in addition to other scripting
languages, then this should be as easy as possible for them to do.  

But if doing fairly reasonable (IMO) things like this requires
understanding tricky concepts and significant Guile-specific changes to
one's application, I think you risk alienating that class of users.

At any rate, I will defer to your (collective) judgement.

> We already have three different ways to do it:
> 
> 1. applicable smobs
> 
> 2. compiled closures (cclo)
> 
> 3. entities and operators (applicable structs)
> 
> Of these, 1 and 2 are easy to do from C.

This sounds promising. But I can't find any documentation on any of
these. In particular, can anyone point me to something for #1 or #2? 

Thank you,

-- 
William <wmorgan@masanjin.net>


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


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

* Re: scm_make_gsubr question
  2003-01-20 19:07     ` William Morgan
@ 2003-01-20 20:03       ` Mikael Djurfeldt
  0 siblings, 0 replies; 9+ messages in thread
From: Mikael Djurfeldt @ 2003-01-20 20:03 UTC (permalink / raw)
  Cc: djurfeldt

William Morgan <wmorgan@masanjin.net> writes:

> Excerpts (reformatted) from Mikael Djurfeldt's mail of 20 Jan 2003 (EST):
>> I don't think it's a good idea to add this to gsubrs.
>
> My question is partially mitigated by your reply below, but I think it's
> worth considering who your target audience is:
>
> If it includes C programmers who want to link Guile in as a scripting
> language, possibly who are not very fluent in Scheme, and possibly (as
> was the case on guile-user recently) in addition to other scripting
> languages, then this should be as easy as possible for them to do.  
>
> But if doing fairly reasonable (IMO) things like this requires
> understanding tricky concepts and significant Guile-specific changes to
> one's application, I think you risk alienating that class of users.
>
> At any rate, I will defer to your (collective) judgement.

I apologize for my short answers.  I'm not intending to be rude.

My previous post was targetted at Neil, another Guile developer.

I think in this case what is needed is not new Guile features but new
documentation.  Unfortunately, I don't have time to write that
documentation.

Applicable smobs are easy to use.  Until documentation is available
you might want to look for the function scm_set_smob_apply in the
Guile sources.

Good luck!

Mikael D.


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


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

* Re: scm_make_gsubr question
  2003-01-19 20:40 scm_make_gsubr question William Morgan
  2003-01-19 23:55 ` Neil Jerram
@ 2003-01-21 15:04 ` Marius Vollmer
  1 sibling, 0 replies; 9+ messages in thread
From: Marius Vollmer @ 2003-01-21 15:04 UTC (permalink / raw)
  Cc: guile-devel

William Morgan <wmorgan@masanjin.net> writes:

> Is there a way to specify, at the time you call scm_make_gsubr, a user
> data parameter which is passed to the corresponding C function?
> [...]
> If not, I would like to submit a patch...

William, in case you are confused about what to do: it would be great
if you can supply a patch for us to look at.

It is true that there are already methods for providing what you are
looking for, but in my opinion, your interface is a very natural one
and C programmers should likely be familiar with it.  So if we can
offer it in a clean way, I think we should.  Maybe it is only a thin
wrapper over applicable smobs, but that would already be an
improvement.

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


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


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

* Re: scm_make_gsubr question
  2003-01-20  9:00   ` Mikael Djurfeldt
  2003-01-20 19:07     ` William Morgan
@ 2003-02-02 22:55     ` Dale P. Smith
  1 sibling, 0 replies; 9+ messages in thread
From: Dale P. Smith @ 2003-02-02 22:55 UTC (permalink / raw)


On Mon, 20 Jan 2003 10:00:48 +0100
Mikael Djurfeldt <djurfeldt@nada.kth.se> wrote:

> Neil Jerram <neil@ossau.uklinux.net> writes:
> 
> >>>>>> "William" == William Morgan <wmorgan@masanjin.net> writes:
> >
> >     William> Is there a way to specify, at the time you call
> >     William> scm_make_gsubr, a user data parameter which is passed to
> >     William> the corresponding C function? [...]

 
> I don't think it's a good idea to add this to gsubrs.
> 
> We already have three different ways to do it:
> 
> 1. applicable smobs
> 
> 2. compiled closures (cclo)
> 
> 3. entities and operators (applicable structs)
> 
> Of these, 1 and 2 are easy to do from C.

I've always wondered about cclo's.  Are there any examples of use?  I
didn't find much in the Guile Reference Manual.

-Dale

-- 
Dale P. Smith
Senior Systems Consultant,      | Treasurer,
Altus Technologies Corporation  | Cleveland Linux Users Group
dsmith@altustech.com            | http://cleveland.lug.net
440-746-9000 x339               |


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


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

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

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-01-19 20:40 scm_make_gsubr question William Morgan
2003-01-19 23:55 ` Neil Jerram
2003-01-20  8:24   ` Rob Browning
2003-01-20  8:58     ` Marius Vollmer
2003-01-20  9:00   ` Mikael Djurfeldt
2003-01-20 19:07     ` William Morgan
2003-01-20 20:03       ` Mikael Djurfeldt
2003-02-02 22:55     ` Dale P. Smith
2003-01-21 15:04 ` Marius Vollmer

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