From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: modifying pointers Date: Fri, 09 Apr 2010 21:46:15 +0200 Message-ID: <87fx34mmt4.fsf@gnu.org> References: <87k4sgpp0w.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1270842396 31551 80.91.229.12 (9 Apr 2010 19:46:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 9 Apr 2010 19:46:36 +0000 (UTC) Cc: guile-devel To: Andy Wingo Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Apr 09 21:46:32 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O0K9w-0002t7-2Q for guile-devel@m.gmane.org; Fri, 09 Apr 2010 21:46:32 +0200 Original-Received: from localhost ([127.0.0.1]:52883 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0K9v-0007lt-Gq for guile-devel@m.gmane.org; Fri, 09 Apr 2010 15:46:31 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O0K9o-0007lF-5s for guile-devel@gnu.org; Fri, 09 Apr 2010 15:46:24 -0400 Original-Received: from [140.186.70.92] (port=50236 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O0K9m-0007kb-3I for guile-devel@gnu.org; Fri, 09 Apr 2010 15:46:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O0K9k-00035R-Aq for guile-devel@gnu.org; Fri, 09 Apr 2010 15:46:21 -0400 Original-Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]:24660) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O0K9k-00035L-3M for guile-devel@gnu.org; Fri, 09 Apr 2010 15:46:20 -0400 X-IronPort-AV: E=Sophos;i="4.52,179,1270418400"; d="scan'208";a="60479870" Original-Received: from reverse-83.fdn.fr (HELO nixey) ([80.67.176.83]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 09 Apr 2010 21:46:18 +0200 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 20 Germinal an 218 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu In-Reply-To: (Andy Wingo's message of "Fri, 09 Apr 2010 18:59:16 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10182 Archived-At: Hello, Andy Wingo writes: > On Fri 09 Apr 2010 18:30, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Andy Wingo 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: >> >> (pass-if "foreign-set! other-null-pointer" >> (let ((f (bytevector->foreign (make-bytevector 2)))) >> (and (not (=3D 0 (foreign-ref f))) >> (begin >> (foreign-set! f 0) >> (=3D 0 (foreign-ref f))) >> (begin >> ;; Here changing the pointer value of F is perfectly valid. >> (foreign-set! f 777) >> (=3D 777 (foreign-ref f)))))) >> >> Here a ((void *) 777) pointer is created. > > I'm just wondering if it is valid to create a ((void*) 777) pointer. > Under what condition is that useful? Under unusual scenarios where the program is communicated a pointer value at the Scheme level, e.g., via =E2=80=98object-address=E2=80=99: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (object-address "sdf") $1 =3D 43230400 scheme@(guile-user)> (define f (bytevector->foreign #vu8(10))) scheme@(guile-user)> f $2 =3D # scheme@(guile-user)> (foreign-ref f) $3 =3D 43814744 scheme@(guile-user)> (foreign-set! f $1) scheme@(guile-user)> (foreign->bytevector f 'u32 0 1) $4 =3D #u32(21) ;; scm_tc7_string --8<---------------cut here---------------end--------------->8--- It opens the door to all sorts of crazy things. :-) > If that is useful, OK; but under what condition is it useful to mutate > the pointer in a foreign pointer object? Why not create a new foreign > pointer object? There=E2=80=99s currently no procedure to create a foreign object from a bi= gnum. (Besides, =E2=80=98foreign-set!=E2=80=99 exists and has always been defined= for all types of foreign pointer objects.) Thanks, Ludo=E2=80=99.