* When to use SCM_DEFINE vs SCM_GPROC vs SCM_PRIMITIVE_GENERIC?
@ 2011-01-28 0:47 Mark H Weaver
2011-01-28 14:37 ` Andy Wingo
0 siblings, 1 reply; 4+ messages in thread
From: Mark H Weaver @ 2011-01-28 0:47 UTC (permalink / raw)
To: guile-devel
I am writing C versions of R6RS div/mod/div0/mod0, as well as
div-and-mod and div0-and-mod0, for numbers.c.
I notice that numbers.c uses three different macros to define public
procedures: SCM_DEFINE, SCM_GPROC, and SCM_PRIMITIVE_GENERIC. I don't
see an obvious logic to the choices of which macro to use. For
example, `exact->inexact' uses SCM_GPROC whereas `inexact->exact' uses
SCM_DEFINE.
One obvious disadvantage to SCM_GPROC is that it doesn't accept a
documentation string.
Can someone please enlighten me about the relevant factors to decide?
What macro do you think I should use for the functions I'm writing?
Note that `div-and-mod' and `div0-and-mod0' will return two values.
One more question: do you think I should give div/mod/div0/mod0 their
short R6RS names by default?
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: When to use SCM_DEFINE vs SCM_GPROC vs SCM_PRIMITIVE_GENERIC?
2011-01-28 0:47 When to use SCM_DEFINE vs SCM_GPROC vs SCM_PRIMITIVE_GENERIC? Mark H Weaver
@ 2011-01-28 14:37 ` Andy Wingo
2011-01-29 15:39 ` Mark H Weaver
0 siblings, 1 reply; 4+ messages in thread
From: Andy Wingo @ 2011-01-28 14:37 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guile-devel
Hi Mark,
On Fri 28 Jan 2011 01:47, Mark H Weaver <mhw@netris.org> writes:
> I notice that numbers.c uses three different macros to define public
> procedures: SCM_DEFINE, SCM_GPROC, and SCM_PRIMITIVE_GENERIC. I don't
> see an obvious logic to the choices of which macro to use. For
> example, `exact->inexact' uses SCM_GPROC whereas `inexact->exact' uses
> SCM_DEFINE.
Yeah, I have no idea why exact->inexact would be extensible and
inexact->exact is not. (And perhaps we should deprecate those functions
in favor of the R6RS spelling, `inexact' and `exact'. Another topic.)
And I don't recall the practical difference between GPROC and
PRIMITIVE_GENERIC.
> What macro do you think I should use for the functions I'm writing?
> Note that `div-and-mod' and `div0-and-mod0' will return two values.
For now, SCM_DEFINE. We can change that later to PRIMITIVE_GENERIC if
needed.
> One more question: do you think I should give div/mod/div0/mod0 their
> short R6RS names by default?
Yes, I think. At least I remember coming to that conclusion at one
point, before I had to move away from that work. We might want opcodes
for some of these, also.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: When to use SCM_DEFINE vs SCM_GPROC vs SCM_PRIMITIVE_GENERIC?
2011-01-28 14:37 ` Andy Wingo
@ 2011-01-29 15:39 ` Mark H Weaver
2011-01-29 17:17 ` Andy Wingo
0 siblings, 1 reply; 4+ messages in thread
From: Mark H Weaver @ 2011-01-29 15:39 UTC (permalink / raw)
To: Andy Wingo; +Cc: guile-devel
Andy Wingo <wingo@pobox.com> writes:
> And I don't recall the practical difference between GPROC and
> PRIMITIVE_GENERIC.
I found the answer. According to a commit message by Mikael Djurfeldt
in 2003, all uses of SCM_GPROC should be converted to use
SCM_PRIMITIVE_GENERIC.
http://blog.gmane.org/gmane.lisp.guile.cvs/month=20030301
I will do this for all extensible functions in numbers.c. I will also
make some other numeric functions extensible. For example, it occurs to
me if we make `inf?', `nan?', and `finite?' extensible, then users will
be able to easily extend them to handle non-real complex values, if
desired.
Best,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: When to use SCM_DEFINE vs SCM_GPROC vs SCM_PRIMITIVE_GENERIC?
2011-01-29 15:39 ` Mark H Weaver
@ 2011-01-29 17:17 ` Andy Wingo
0 siblings, 0 replies; 4+ messages in thread
From: Andy Wingo @ 2011-01-29 17:17 UTC (permalink / raw)
To: Mark H Weaver; +Cc: guile-devel
On Sat 29 Jan 2011 16:39, Mark H Weaver <mhw@netris.org> writes:
> Andy Wingo <wingo@pobox.com> writes:
>> And I don't recall the practical difference between GPROC and
>> PRIMITIVE_GENERIC.
>
> I found the answer. According to a commit message by Mikael Djurfeldt
> in 2003, all uses of SCM_GPROC should be converted to use
> SCM_PRIMITIVE_GENERIC.
>
> http://blog.gmane.org/gmane.lisp.guile.cvs/month=20030301
>
> I will do this for all extensible functions in numbers.c. I will also
> make some other numeric functions extensible. For example, it occurs to
> me if we make `inf?', `nan?', and `finite?' extensible, then users will
> be able to easily extend them to handle non-real complex values, if
> desired.
Sounds great to me. Thanks for doing the archeology!
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-29 17:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-28 0:47 When to use SCM_DEFINE vs SCM_GPROC vs SCM_PRIMITIVE_GENERIC? Mark H Weaver
2011-01-28 14:37 ` Andy Wingo
2011-01-29 15:39 ` Mark H Weaver
2011-01-29 17:17 ` 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).