From: Alex Vong <alexvong1995@gmail.com>
To: Mark H Weaver <mhw@netris.org>
Cc: guile-user@gnu.org, Pierre LINDENBAUM <Pierre.Lindenbaum@univ-nantes.fr>
Subject: Re: function registered with scm_c_define_gsubr: how can i handle an optional parameter?
Date: Sat, 16 Dec 2017 00:59:29 +0800 [thread overview]
Message-ID: <87y3m4udu6.fsf@gmail.com> (raw)
In-Reply-To: <87y3m4za7d.fsf@netris.org> (Mark H. Weaver's message of "Fri, 15 Dec 2017 03:06:46 -0500")
[-- Attachment #1: Type: text/plain, Size: 1966 bytes --]
Mark H Weaver <mhw@netris.org> writes:
> Hi Alex,
>
> Alex Vong <alexvong1995@gmail.com> writes:
>
>> Oh, I didn't really think too much about this. I always thought immediate
>> objects like SCM_EOL, SCM_BOOL_T, ..., SCM_UNDEFINED can be compared
>> using '=='. Is this an implementation detail that I should not depend
>> on?
>
> That's right. You should not rely on SCM being represented in any
> particular way. In C, '==' works only on pointers and values of
> arithmetic type, not on structs or unions. Therefore, in general, you
> cannot use '==' on a value of an abstract type without some knowledge of
> the underlying type.
>
> Guile's API is designed to avoid propagating assumptions about the SCM
> type. Please use only the functions and macros in Guile's public API to
> inspect, compare, or manipulate values of type SCM. This will enable
> Guile implementors and other hackers to experiment with other SCM data
> representations. We reserve the right to change the SCM type in future
> versions of Guile (but not within a stable release series e.g. 2.2.x).
>
> I should also mention that Guile provides a mechanism to check for such
> mistakes. If you test compiling your libguile-using code with
> -DSCM_DEBUG_TYPING_STRICTNESS=2, it will change SCM to be a struct type,
> and you'll get a compile error if you attempt to use '==' on values of
> type SCM. (Note that this will produce code that is ABI-incompatible
> with libguile compiled using the default SCM_DEBUG_TYPING_STRICTNESS=1
> setting, so typically you would set SCM_DEBUG_TYPING_STRICTNESS=2 only
> as a compile-time check.)
>
> For details, see the description of SCM_DEBUG_TYPING_STRICTNESS in
> __scm.h, and also the top few pages of tags.h, which describes the
> fundamental concepts of how Guile Scheme objects are represented in C,
> including the definitions of the SCM type and the 'scm_is_eq' macro.
>
> Regards,
> Mark
Thanks for your informative post!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
prev parent reply other threads:[~2017-12-15 16:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 21:50 function registered with scm_c_define_gsubr: how can i handle an optional parameter? Pierre LINDENBAUM
2017-12-14 10:19 ` Alex Vong
2017-12-14 12:30 ` Mark H Weaver
2017-12-14 13:50 ` Alex Vong
2017-12-15 8:06 ` Mark H Weaver
2017-12-15 16:59 ` Alex Vong [this message]
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=87y3m4udu6.fsf@gmail.com \
--to=alexvong1995@gmail.com \
--cc=Pierre.Lindenbaum@univ-nantes.fr \
--cc=guile-user@gnu.org \
--cc=mhw@netris.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).