From: ludo@gnu.org (Ludovic Courtès)
To: Andy Wingo <wingo@pobox.com>
Cc: guile-devel <guile-devel@gnu.org>
Subject: Re: modifying pointers
Date: Fri, 09 Apr 2010 18:30:07 +0200 [thread overview]
Message-ID: <87k4sgpp0w.fsf@gnu.org> (raw)
In-Reply-To: <m3pr29yp0u.fsf@pobox.com> (Andy Wingo's message of "Fri, 09 Apr 2010 11:05:21 +0200")
Hi,
Andy Wingo <wingo@pobox.com> writes:
> You added a change to foreign-set! for %null-pointer. Would it not make
> sense instead to make foreign pointers of type "void" unsettable?
Not necessarily. See the test that was added:
--8<---------------cut here---------------start------------->8---
(pass-if "foreign-set! other-null-pointer"
(let ((f (bytevector->foreign (make-bytevector 2))))
(and (not (= 0 (foreign-ref f)))
(begin
(foreign-set! f 0)
(= 0 (foreign-ref f)))
(begin
;; Here changing the pointer value of F is perfectly valid.
(foreign-set! f 777)
(= 777 (foreign-ref f))))))
--8<---------------cut here---------------end--------------->8---
Here a ((void *) 777) pointer is created.
However, this is not allowed for ‘%null-pointer’ because (1) that would
change its semantics, and (2) it’s defined as ‘const’ anyway, so
modifying it leads to a segfault.
Thanks,
Ludo’.
next prev parent reply other threads:[~2010-04-09 16:30 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-09 9:05 modifying pointers Andy Wingo
2010-04-09 16:30 ` Ludovic Courtès [this message]
2010-04-09 16:59 ` Andy Wingo
2010-04-09 19:46 ` Ludovic Courtès
2010-04-09 20:15 ` 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=87k4sgpp0w.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/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).