* bug#10974: guile-user@gnu.org
@ 2012-03-08 11:36 Alexei Matveev
2012-07-02 9:38 ` Ludovic Courtès
0 siblings, 1 reply; 8+ messages in thread
From: Alexei Matveev @ 2012-03-08 11:36 UTC (permalink / raw)
To: 10974
Hi, All,
For use from a Fortran program I am collecting API fixes for libguile.so
as wrapper functions for what is provided to C-programs as macros.
I noted that some of the macros are function-macros some are symbol
macros. An example of the latter is
#define scm_to_int scm_to_int23
This is inconsistent and makes escaping such macros slightly more difficult.
(Honestly I dont know a way yet).
One guile developer on IRC said this is "probably a good thing to fix"
so I report
it here. I dont build Guile 2 myself as the installations I use are quite
dated/conservative.
As a background, Fortran allows you to declare "foreign" functions, for example,
like this:
type, public, bind(c) :: scm_t
private
integer(c_intptr_t) :: do_not_ever_use
end type scm_t
interface
function scm_symbol_p (obj) result (yes) bind (c)
type(scm_t), intent(in), value :: obj
type(scm_t) :: yes
end function scm_symbol_p
...
end interface
This makes use of library functions quite handy. But it does not provide a
way to access a C-macro, naturally.
Alexei
#include <libguile.h>
SCM guile_macro_scm_from_int (int i);
int guile_macro_scm_to_int (SCM obj);
int (scm_is_true) (SCM obj);
int (scm_is_symbol) (SCM obj);
int (scm_is_null) (SCM obj);
SCM (scm_eol) (void);
SCM guile_macro_scm_from_int (int i)
{
return scm_from_int(i);
}
int guile_macro_scm_to_int (SCM obj)
{
return scm_to_int(obj);
}
int (scm_is_true) (SCM obj)
{
return scm_is_true(obj);
}
int (scm_is_symbol) (SCM obj)
{
return scm_is_symbol(obj);
}
int (scm_is_null) (SCM obj)
{
return scm_is_null(obj);
}
SCM (scm_eol) ()
{
return SCM_EOL;
}
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
2012-03-08 11:36 bug#10974: guile-user@gnu.org Alexei Matveev
@ 2012-07-02 9:38 ` Ludovic Courtès
2012-07-02 10:15 ` Alexei Matveev
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Ludovic Courtès @ 2012-07-02 9:38 UTC (permalink / raw)
To: Alexei Matveev; +Cc: 10974
Hi,
Sorry for the late reply.
Alexei Matveev <alexei.matveev@gmail.com> skribis:
> For use from a Fortran program I am collecting API fixes for libguile.so
> as wrapper functions for what is provided to C-programs as macros.
> I noted that some of the macros are function-macros some are symbol
> macros. An example of the latter is
>
> #define scm_to_int scm_to_int23
The macros in numbers.h that are “symbol macros”, such as
‘scm_from_int’, allow users to write code like:
&scm_from_int
This wouldn’t be possible if these were function macros.
Thus, I think things will have to remain this way.
What do you think?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
2012-07-02 9:38 ` Ludovic Courtès
@ 2012-07-02 10:15 ` Alexei Matveev
[not found] ` <CACMrLAeaLn4Bw13TitmeAO8sympbsvFRkM+skFrMTvSe0iYf2w@mail.gmail.com>
2012-07-02 21:45 ` Andy Wingo
2 siblings, 0 replies; 8+ messages in thread
From: Alexei Matveev @ 2012-07-02 10:15 UTC (permalink / raw)
To: Ludovic Courtès, guile-devel; +Cc: 10974
On Mon, Jul 2, 2012 at 11:38 AM, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> For use from a Fortran program I am collecting API fixes for libguile.so
>> as wrapper functions for what is provided to C-programs as macros.
>> I noted that some of the macros are function-macros some are symbol
>> macros. An example of the latter is
>>
>> #define scm_to_int scm_to_int23
>
> The macros in numbers.h that are “symbol macros”, such as
> ‘scm_from_int’, allow users to write code like:
>
> &scm_from_int
>
> This wouldn’t be possible if these were function macros.
>
> Thus, I think things will have to remain this way.
Hi,
It's ok. You may close it.
I still think it could be less confusing if the libguile.so implemented/provided
functions as advertised in Guile API docs for the sake of interfacing to
languages other than C. And &scm_from_int wold also work if it were a real
function.
But there are many more macros, so such a link-time interface would be a
lot of work, I realize by now.
Alexei
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
[not found] ` <CACMrLAeaLn4Bw13TitmeAO8sympbsvFRkM+skFrMTvSe0iYf2w@mail.gmail.com>
@ 2012-07-02 19:17 ` Ludovic Courtès
0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2012-07-02 19:17 UTC (permalink / raw)
To: Alexei Matveev; +Cc: guile-devel, 10974-done
Hi,
Alexei Matveev <alexei.matveev@gmail.com> skribis:
> It's ok. You may close it.
Thanks.
> I still think it could be less confusing if the libguile.so implemented/provided
> functions as advertised in Guile API docs for the sake of interfacing to
> languages other than C. And &scm_from_int wold also work if it were a real
> function.
>
> But there are many more macros, so such a link-time interface would be a
> lot of work, I realize by now.
Yeah. Though here, you could still write bindings for ‘scm_from_int32’
(the real function) instead of ‘scm_from_int’, for instance, no?
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
2012-07-02 9:38 ` Ludovic Courtès
2012-07-02 10:15 ` Alexei Matveev
[not found] ` <CACMrLAeaLn4Bw13TitmeAO8sympbsvFRkM+skFrMTvSe0iYf2w@mail.gmail.com>
@ 2012-07-02 21:45 ` Andy Wingo
2012-07-02 22:35 ` Ludovic Courtès
2 siblings, 1 reply; 8+ messages in thread
From: Andy Wingo @ 2012-07-02 21:45 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 10974, Alexei Matveev
On Mon 02 Jul 2012 11:38, ludo@gnu.org (Ludovic Courtès) writes:
> The macros in numbers.h that are “symbol macros”, such as
> ‘scm_from_int’, allow users to write code like:
>
> &scm_from_int
>
> This wouldn’t be possible if these were function macros.
Interesting, I hadn't thought of that.
> Thus, I think things will have to remain this way.
Would this be "fixed" if we changed these to be implemented as inline
functions?
Dunno, just thinking out loud.
Andy
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
2012-07-02 21:45 ` Andy Wingo
@ 2012-07-02 22:35 ` Ludovic Courtès
2012-07-02 23:17 ` Andy Wingo
0 siblings, 1 reply; 8+ messages in thread
From: Ludovic Courtès @ 2012-07-02 22:35 UTC (permalink / raw)
To: Andy Wingo; +Cc: 10974, Alexei Matveev
Hi,
Andy Wingo <wingo@pobox.com> skribis:
> Would this be "fixed" if we changed these to be implemented as inline
> functions?
In some way, though their address could still not be taken.
Thanks,
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
2012-07-02 22:35 ` Ludovic Courtès
@ 2012-07-02 23:17 ` Andy Wingo
2012-07-03 8:09 ` Ludovic Courtès
0 siblings, 1 reply; 8+ messages in thread
From: Andy Wingo @ 2012-07-02 23:17 UTC (permalink / raw)
To: Ludovic Courtès; +Cc: 10974, Alexei Matveev
On Tue 03 Jul 2012 00:35, ludo@gnu.org (Ludovic Courtès) writes:
> Andy Wingo <wingo@pobox.com> skribis:
>
>> Would this be "fixed" if we changed these to be implemented as inline
>> functions?
>
> In some way, though their address could still not be taken.
Sorry to be obtuse, but with our inline functions, we also residualize a
concrete instantiation (via the inline.c madness). Does that not work?
A
--
http://wingolog.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* bug#10974: guile-user@gnu.org
2012-07-02 23:17 ` Andy Wingo
@ 2012-07-03 8:09 ` Ludovic Courtès
0 siblings, 0 replies; 8+ messages in thread
From: Ludovic Courtès @ 2012-07-03 8:09 UTC (permalink / raw)
To: Andy Wingo; +Cc: 10974, Alexei Matveev
Hi,
Andy Wingo <wingo@pobox.com> skribis:
> On Tue 03 Jul 2012 00:35, ludo@gnu.org (Ludovic Courtès) writes:
>
>> Andy Wingo <wingo@pobox.com> skribis:
>>
>>> Would this be "fixed" if we changed these to be implemented as inline
>>> functions?
>>
>> In some way, though their address could still not be taken.
>
> Sorry to be obtuse, but with our inline functions, we also residualize a
> concrete instantiation (via the inline.c madness). Does that not work?
Yes, right, so we could just inline them all.
Ludo’.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-07-03 8:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-08 11:36 bug#10974: guile-user@gnu.org Alexei Matveev
2012-07-02 9:38 ` Ludovic Courtès
2012-07-02 10:15 ` Alexei Matveev
[not found] ` <CACMrLAeaLn4Bw13TitmeAO8sympbsvFRkM+skFrMTvSe0iYf2w@mail.gmail.com>
2012-07-02 19:17 ` Ludovic Courtès
2012-07-02 21:45 ` Andy Wingo
2012-07-02 22:35 ` Ludovic Courtès
2012-07-02 23:17 ` Andy Wingo
2012-07-03 8:09 ` Ludovic Courtès
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).