From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Alex Vong Newsgroups: gmane.lisp.guile.user 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 Message-ID: <87y3m4udu6.fsf@gmail.com> References: <877etpwr1c.fsf@gmail.com> <876099cx0l.fsf@netris.org> <87374dwh8c.fsf@gmail.com> <87y3m4za7d.fsf@netris.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1513357246 16506 195.159.176.226 (15 Dec 2017 17:00:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 15 Dec 2017 17:00:46 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cc: guile-user@gnu.org, Pierre LINDENBAUM To: Mark H Weaver Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Fri Dec 15 18:00:36 2017 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ePtLe-0003WQ-Ee for guile-user@m.gmane.org; Fri, 15 Dec 2017 18:00:34 +0100 Original-Received: from localhost ([::1]:47619 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtLj-0004Ud-IG for guile-user@m.gmane.org; Fri, 15 Dec 2017 12:00:39 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ePtKy-0004UW-PI for guile-user@gnu.org; Fri, 15 Dec 2017 11:59:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ePtKv-0002Qc-NJ for guile-user@gnu.org; Fri, 15 Dec 2017 11:59:52 -0500 Original-Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:40999) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ePtKv-0002P8-HB for guile-user@gnu.org; Fri, 15 Dec 2017 11:59:49 -0500 Original-Received: by mail-pf0-x22d.google.com with SMTP id j28so6539947pfk.8 for ; Fri, 15 Dec 2017 08:59:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=70+XF7cweAwZiF8yl/2dnZ9QSLBjLzrYPevhEZ6A7lY=; b=Ntqjadlsx8IyI1T2XdIq1S+2eI4OY9JYU8zdgbSN87J0TL6lCUB0O/Nal6yXFM80o3 ZP4Q+VCQoSpOT1VdEu8d7rqk37jYN4cuoz4Q2EsU7hJg1o1zRkP8CpGqUakTN825ue66 m2mxQYIbY6RVjwD3BX7T9+y9Wipz+JjxasFWtgjQuHgIpNu7rgPWtXg6q8RUSJ4pp7Bt oeW0bTiM0K9dzR+jTzd6QtFqkBRnLYNz22ScfHhUbZY6GD/LDiHR041wiwnJWjaj9R3C 0nk87Rp3h2nug4467OyotOWigTjY9vV890oVG655BRa8KEnIVgCXfsySRskVx6r/MUfP nY9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=70+XF7cweAwZiF8yl/2dnZ9QSLBjLzrYPevhEZ6A7lY=; b=Exlvad1xo5yw5KYRhN8e7eF2bURSXzaoaATrt6oPGmcn8hH3nG6mAJP5wEvH86pf1h lu7R1xU8O1WIEROk127ktdxtVGf+zFOpsVeX5hDXcqy7Rk1pFZ0+wcHtnsz+VN2PZNRX W22hzqxJWgqRhy0RmG4KID2meu7/jgn02CxL4mVvIPF3kL9iuj6FUhqxj83kBdvjEECC EAjY4ydh6aJnmsZrrA698LjcbyOLvoYCaTO1K3AVBNMgyCaWA7Sl45D/Q9y2SqCxIMyC BOziiwsB/H1Le55X9Q9yOwn6z2YkQ/6uE52qvD437AvGRR0CFAg7+dAFiCgtb1X9IZio 3MNA== X-Gm-Message-State: AKGB3mJUChotZv43FA8PAN9YIxxpiI1s2hDBsqfM0gOC0mNQxbNiSIJa gLX0em/JlCVzoWv9DKmYOmE= X-Google-Smtp-Source: ACJfBos9kMBm6RpheC3TBzsQS3Kkutpyfd//Y24SNKQnBQ9d8tKOAga3r4n4zlOo3Jmjpt094uKegA== X-Received: by 10.101.97.15 with SMTP id z15mr12358847pgu.267.1513357188088; Fri, 15 Dec 2017 08:59:48 -0800 (PST) Original-Received: from debian (n218103180088.netvigator.com. [218.103.180.88]) by smtp.gmail.com with ESMTPSA id l80sm13537815pfk.67.2017.12.15.08.59.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Dec 2017 08:59:47 -0800 (PST) In-Reply-To: <87y3m4za7d.fsf@netris.org> (Mark H. Weaver's message of "Fri, 15 Dec 2017 03:06:46 -0500") X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22d X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.org gmane.lisp.guile.user:14368 Archived-At: --=-=-= Content-Type: text/plain Mark H Weaver writes: > Hi Alex, > > Alex Vong 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! --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdZDkzSn0Cycogr9IxYq4eRf1Ea4FAloz/3IACgkQxYq4eRf1 Ea4l2Q/+O8YagyPBr4rGkMaKvruQVXjKannZgozgF+tMwuFImE5paLBuMjN5oeuo 5yn6d0ZwOqr/IBO8gvHVLcngzM5IUqvDRNsqlaojTRt+xXtR/aWg7aiMZOC+/TLO ZU3Wdu5F5T6gpm6HM2M1tgzInF5O8qad0dyXAEsLCFnMgbHQLjFcatWT6IEBUvyw qg+UsZTBBhpTkyE/9o96jEoOOS+95/EKZQZsgYYLeG9g8s6r1/igqPr2uhNZyMfU x/61nupIfo3hEKFOGohTY4IeJazg0Elzcw1OJqAbB5hRawundUVW8ceDxYur5ZsB zaTatmlnhHKG+CQAfMYdK5K5UZvyU7FUiSWmFzOL6MWYQxev1BCbAi40yyEXFzm1 vRLzmeF3+okFVNAPVXzhipEHoopZHrAU6uS9ivaOkwdf7yqOu5LTTT4J7o0Dba4g hnVQ0aawhRIqv8KVK1Kj+ccJPtDqyWhIw1KSs7oe1qKXBsk4lKMaTmnPnq3Rv7op 1I98U9GuF9L5BtWCFIn2PaRfB7vHW1YFGIb5uttFYoA6Y/k3tOQw8IhQ7EvwB3hr XrDfZGQZyZo8n1SXiF+OMWx3SvDuunAxqBYEQIwFENNJ+2D/PoZJjWvFEwV8gX9G EKH/NVgPib0ppZYbNfrFjYPs+yhMYQlwv1KqX/fHDybe25b2rEc= =ByS/ -----END PGP SIGNATURE----- --=-=-=--