From: Andy Wingo <wingo@pobox.com>
To: Alexei Matveev <alexei.matveev@gmail.com>
Cc: guile-user@gnu.org, guile-devel <guile-devel@gnu.org>
Subject: Re: Guile API for foreign languages: proposing SCM scm_list_0(void)
Date: Sat, 12 Jan 2013 16:16:37 +0100 [thread overview]
Message-ID: <87txqmwhwq.fsf@pobox.com> (raw)
In-Reply-To: <CACMrLAddN9W7C3ATHPTPpsqXJyQ4A0sbDwAZ4vo27jEL-iiS9Q@mail.gmail.com> (Alexei Matveev's message of "Mon, 2 Jul 2012 13:11:14 +0200")
Hi Alexei,
On Mon 02 Jul 2012 13:11, Alexei Matveev <alexei.matveev@gmail.com> writes:
> To raise this question again: I ended up with a wrapper
> function for a Fortran project equivalent to the scm_list_0()
> quoted below. The reason is accessing macros from languages
> other than C is cumbersome.
>
> Contrary to scm_from/to_int, scm_is_* and other macros
> adding this as a funciton one is a no-brainer, since it would
> be a new API call and raises no compatibility concerns.
Apologies for ignoring you. I think that the thought that if we wanted
to follow through the logic of making Guile's C API available to non-C
languages, we should do so either all the way or not at all.
Each additional function added to Guile's ABI imposes additional cost in
runtime memory, ELF symbol resolution, and (to a degree) startup time,
without providing any benefits to C users. On the other hand, if we are
only talking about 2 functions (say), then clearly we should do it. So
part of the question is, how much work are we talking about?
I grepped the header files for lines starting with "#define SCM_",
munged out the name of the macro and sorted them for uniqueness. That
was around 1200 macros. I filtered out certain kinds of macros:
* those ending in _H (header guards)
* those starting with SCM_I_ (internal macros)
* those containing _BIT (implementation details)
* SCM_VALIDATE_ macros (there are corresponding C procedures)
That left me with about 900 macros.
I then filtered out all macros that had a corresponding C binding. For
example, SCM_CAR has a C procedure, `scm_car'. That left me with about
780 macros.
Finally, from this list, I filtered out those symbols that did not
appear in our documentation. That resulted in the following 77 symbols:
SCM_ALLOW_INTS
SCM_ARG1
SCM_ARG2
SCM_ARG3
SCM_ARG4
SCM_ARG5
SCM_ARG6
SCM_ARG7
SCM_ARGn
SCM_ASSERT_TYPE
SCM_BOOL_F
SCM_BOOL_T
SCM_BYTEVECTOR_CONTENTS
SCM_CELL_OBJECT
SCM_CELL_OBJECT_0
SCM_CELL_OBJECT_1
SCM_CELL_TYPE
SCM_CELL_WORD
SCM_CELL_WORD_0
SCM_CELL_WORD_1
SCM_DEFER_INTS
SCM_ELISP_NIL
SCM_EOF_VAL
SCM_EOL
SCM_FRAME_DATA_ADDRESS
SCM_FRAME_LOWER_ADDRESS
SCM_FRAME_UPPER_ADDRESS
SCM_GLOBAL_KEYWORD
SCM_GLOBAL_VARIABLE
SCM_GLOBAL_VARIABLE_INIT
SCM_GPROC
SCM_HOOKP
SCM_IMP
SCM_NEWSMOB
SCM_NEWSMOB2
SCM_NEWSMOB3
SCM_PTAB_ENTRY
SCM_PTOBNUM
SCM_REGISTER_PROC
SCM_RETURN_NEWSMOB
SCM_RETURN_NEWSMOB2
SCM_RETURN_NEWSMOB3
SCM_SET_CELL_OBJECT
SCM_SET_CELL_OBJECT_0
SCM_SET_CELL_OBJECT_1
SCM_SET_CELL_TYPE
SCM_SET_CELL_WORD
SCM_SET_CELL_WORD_0
SCM_SET_CELL_WORD_1
SCM_SET_SMOB_DATA
SCM_SET_SMOB_DATA_2
SCM_SET_SMOB_DATA_3
SCM_SET_SMOB_FLAGS
SCM_SET_SMOB_OBJECT
SCM_SET_SMOB_OBJECT_2
SCM_SET_SMOB_OBJECT_3
SCM_SIMPLE_VECTOR_LENGTH
SCM_SIMPLE_VECTOR_REF
SCM_SIMPLE_VECTOR_SET
SCM_SMOB_DATA
SCM_SMOB_DATA_2
SCM_SMOB_DATA_3
SCM_SMOB_FLAGS
SCM_SMOB_OBJECT
SCM_SMOB_OBJECT_2
SCM_SMOB_OBJECT_2_LOC
SCM_SMOB_OBJECT_3
SCM_SMOB_OBJECT_3_LOC
SCM_SMOB_OBJECT_LOC
SCM_SMOB_PREDICATE
SCM_TICK
SCM_UNBNDP
SCM_UNBOUND
SCM_UNDEFINED
SCM_UNSPECIFIED
SCM_VARIABLE_INIT
The next step would be to manually check which of these symbols are
actually necessary. Perhaps I can leave this job to someone else :)
Regards,
Andy
--
http://wingolog.org/
next prev parent reply other threads:[~2013-01-12 15:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-02 11:11 Guile API for foreign languages: proposing SCM scm_list_0(void) Alexei Matveev
2013-01-12 15:16 ` Andy Wingo [this message]
2013-01-14 22:44 ` Alexei Matveev
2013-01-15 9:06 ` Andy Wingo
2013-01-15 9:20 ` Ludovic Courtès
2013-01-22 10:55 ` Andy Wingo
2013-01-31 11:27 ` Andy Wingo
2013-01-31 11:45 ` Andy Wingo
2013-01-31 13:37 ` Noah Lavine
2013-01-31 14:13 ` Alexei Matveev
2013-01-31 16:57 ` Alexei Matveev
2013-01-31 17:23 ` Andy Wingo
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=87txqmwhwq.fsf@pobox.com \
--to=wingo@pobox.com \
--cc=alexei.matveev@gmail.com \
--cc=guile-devel@gnu.org \
--cc=guile-user@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).