<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body ><div><br></div><div><br></div><div><br></div><div><div style="font-size:9px;color:#575757">Sent via the Samsung GALAXY S® 5, an AT&T 4G LTE smartphone</div></div><div></div><br><br>-------- Original message --------<br>From: users-request@racket-lang.org <br>Date:02/02/2015 11:00 AM (GMT-06:00) <br>To: users@racket-lang.org <br>Cc: <br>Subject: users Digest, Vol 114, Issue 3 <br><br>Send users mailing list submissions to<br> users@racket-lang.org<br><br>To subscribe or unsubscribe via the World Wide Web, visit<br> http://lists.racket-lang.org/users/listinfo<br>or, via email, send a message with subject or body 'help' to<br> users-request@racket-lang.org<br><br>You can reach the person managing the list at<br> users-owner@racket-lang.org<br><br>When replying, please edit your Subject line so it is more specific<br>than "Re: Contents of users digest..."<br><br><br>[Racket Users list:<br> http://lists.racket-lang.org/users ]<br><br><br>Today's Topics:<br><br> 1. Re: forward pointer declarations (Anthony Carrico)<br> 2. Re: forward pointer declarations (Sam Tobin-Hochstadt)<br> 3. Re: forward pointer declarations (Anthony Carrico)<br><br><br>----------------------------------------------------------------------<br><br>Message: 1<br>Date: Mon, 02 Feb 2015 08:02:43 -0500<br>From: Anthony Carrico <acarrico@memebeam.org><br>To: Matthew Flatt <mflatt@cs.utah.edu><br>Cc: racket Users <users@racket-lang.org><br>Subject: Re: [racket] forward pointer declarations<br>Message-ID: <54CF7573.6060000@memebeam.org><br>Content-Type: text/plain; charset="utf-8"<br><br>On 02/02/2015 01:17 AM, Matthew Flatt wrote:<br>> It's also valid to reference `wl_interface-pointer` directly:<br>...<br>> <br>> I don't have a nicer solution if you want to refer to<br>> `_wl_message-pointer`, though.<br>> <br><br>The forward reference is actually in wl_message, like this:<br><br>(define-cstruct _wl_message<br> ((name _string/utf-8)<br> (signature _string/utf-8)<br> (types (_cpointer 'wl_interface))))<br><br>(define-cstruct _wl_interface<br> ((name _string/utf-8)<br> (version _int)<br> (method_count _int)<br> (methods _wl_message-pointer)<br> (event_count _int)<br> (events _wl_message-pointer)))<br><br>I ended up just inlining (_cpointer 'wl_interface) for the forward<br>reference. This ends up creating two (_cpointer 'wl_interface) ctypes,<br>but it's no problem, correct?<br><br>I don't think it is possible to "reference 'wl_interface-pointer'<br>directly" as you suggest in this case because of the "cannot reference<br>an identifier before its definition" error.<br><br>-- <br>Anthony Carrico<br><br><br>-------------- next part --------------<br>A non-text attachment was scrubbed...<br>Name: signature.asc<br>Type: application/pgp-signature<br>Size: 181 bytes<br>Desc: OpenPGP digital signature<br>URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/f5494983/attachment-0001.sig><br><br>------------------------------<br><br>Message: 2<br>Date: Mon, 02 Feb 2015 14:04:25 +0000<br>From: Sam Tobin-Hochstadt <samth@cs.indiana.edu><br>To: Anthony Carrico <acarrico@memebeam.org>, Matthew Flatt<br> <mflatt@cs.utah.edu><br>Cc: racket Users <users@racket-lang.org><br>Subject: Re: [racket] forward pointer declarations<br>Message-ID:<br> <CAK=HD+bSzeuvOm+pjuM53MfidOfy6=mJC0M7KwSjDJ7qj3LwGQ@mail.gmail.com><br>Content-Type: text/plain; charset="utf-8"<br><br>Maybe a ctype which is a delay node, along the lines of<br>'recursive-contract', is the right thing here.<br><br>Sam<br><br>On Mon, Feb 2, 2015, 8:05 AM Anthony Carrico <acarrico@memebeam.org> wrote:<br><br>> On 02/02/2015 01:17 AM, Matthew Flatt wrote:<br>> > It's also valid to reference `wl_interface-pointer` directly:<br>> ...<br>> ><br>> > I don't have a nicer solution if you want to refer to<br>> > `_wl_message-pointer`, though.<br>> ><br>><br>> The forward reference is actually in wl_message, like this:<br>><br>> (define-cstruct _wl_message<br>> ((name _string/utf-8)<br>> (signature _string/utf-8)<br>> (types (_cpointer 'wl_interface))))<br>><br>> (define-cstruct _wl_interface<br>> ((name _string/utf-8)<br>> (version _int)<br>> (method_count _int)<br>> (methods _wl_message-pointer)<br>> (event_count _int)<br>> (events _wl_message-pointer)))<br>><br>> I ended up just inlining (_cpointer 'wl_interface) for the forward<br>> reference. This ends up creating two (_cpointer 'wl_interface) ctypes,<br>> but it's no problem, correct?<br>><br>> I don't think it is possible to "reference 'wl_interface-pointer'<br>> directly" as you suggest in this case because of the "cannot reference<br>> an identifier before its definition" error.<br>><br>> --<br>> Anthony Carrico<br>><br>><br>> ____________________<br>> Racket Users list:<br>> http://lists.racket-lang.org/users<br>><br>-------------- next part --------------<br>An HTML attachment was scrubbed...<br>URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/0b9778b6/attachment-0001.html><br><br>------------------------------<br><br>Message: 3<br>Date: Mon, 02 Feb 2015 09:41:46 -0500<br>From: Anthony Carrico <acarrico@memebeam.org><br>To: users@racket-lang.org<br>Subject: Re: [racket] forward pointer declarations<br>Message-ID: <54CF8CAA.60500@memebeam.org><br>Content-Type: text/plain; charset="windows-1252"<br><br>Along these lines, I also am a little foggy on unions. This:<br> http://docs.racket-lang.org/foreign/C_Union_Types.html<br><br>says, "Unions are always treated like structs." But I have no idea what<br>that phrase means. I don't get the impression that unions have tags like<br>structs can have. Or can they? Maybe any pointer can be tagged? For example:<br><br>(define _wl_argument<br> (_union _int32<br> _uint32<br> _wl_fixed<br> _string/utf-8<br> (_cpointer/null 'wl_object)<br> _uint32<br> _wl_array-pointer<br> _int32))<br><br>Now suppose I need to pass an array of _wl_argument. Does it even make<br>sense to use a tag in the _cpointer?<br><br>(define _wl_argument-pointer (_cpointer 'wl_argument))<br><br>(define-wl-client wl_proxy_marshal_array_constructor<br> (_fun #:save-errno 'posix<br> _wl_proxy-pointer<br> _uint32<br> _wl_argument-pointer<br> _wl_interface-pointer<br> -> _wl_proxy-pointer/null<br> ))<br><br>So as I said, I'm just a little foggy on some of the concepts, but I do<br>think the FFI is very nice. Maybe I'm just trying to use stronger typing<br>than actually exists in the ffi. I've started reading<br>Eli Barzilay/Dmitry Orlovsky "Foreign Interface for PLT Scheme".<br><br>-- <br>Anthony Carrico<br><br><br>-------------- next part --------------<br>A non-text attachment was scrubbed...<br>Name: signature.asc<br>Type: application/pgp-signature<br>Size: 181 bytes<br>Desc: OpenPGP digital signature<br>URL: <http://lists.racket-lang.org/users/archive/attachments/20150202/b5d986ce/attachment-0001.sig><br><br>End of users Digest, Vol 114, Issue 3<br>*************************************<br></body></html>