[racket] FFI question: 0 microseconds returned from gettimeofday call

From: keydana at gmx.de (keydana at gmx.de)
Date: Sun Jul 17 12:00:16 EDT 2011

Hi Thomas,

thanks again for your "lecture in c thinking", this is very helpful for someone who made her way into programming, and IT in general, starting with Java 5 and Racket (pardon me, it used to be called scheme then :-; ) :-)

>> 
> 
> Correct, the caller has to provide a storage location for the output
> she's interested in and may pass NULL to indicate that no storage has
> been allocated because she's not interested in a return value.

That's good to know, I really was not aware of such a convention - but it makes sense as soon as you think about pointers as "storage allocation"!
In fact I remember I've already told myself before to always think of "storage allocation" when I read "pointer", but when you're not exposed to something for a long time you just forget things ...


> 
> In C++ output parameters are often declared using reference types, which
> are a special kind of pointer types that is always implicitly
> dereferenced when used in expressions and cannot be set to NULL


Yes, I think the C++ references were closer somehow to what I assumed (closer in "meaning"/intent I mean, not technically). (Not that I've worked with C++ too much either, just some very cursory exposure... :-;)


Thanks again,
Sigrid



> explicitly (at least not if the expression used to do so is simple
> enough for the compiler to realize what you're up to ;-)
> 
> If you declare a (_ptr o _something) type, racket always allocates space
> for a something, passes the pointer to the foreign function and then
> dereferences it to extract the _something after the foreign function
> returns. Racket should indeed never pass a NULL pointer here.
> 
> Ciao,
> Thomas
> 
> 
> -- 
> When C++ is your hammer, every problem looks like your thumb.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110717/eec4c471/attachment.html>

Posted on the users mailing list.