caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re:  [Caml-list] C ffi issue
@ 2001-09-19  9:55 Damien Doligez
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 2001-09-19  9:55 UTC (permalink / raw)
  To: caml-list, jehenrik

>According to the C interface documentation, assignments to tuple
>members must be done with the modify(value*,value) function.
>However, local variables once registered with the GC can apparently
>just be assigned.  If I do this instead will anything crash?
>
>        CAMLlocal1(nontuple);
>        modify(&nontuple,mydata);  // should just be nontuple=mydata;

Although it was not designed for this use, modify will work correctly
in this context.  I now guarantee that it won't crash if you use it in
this way.  It is a bit less efficient than direct assignment
(it does a little pointer arithmetic plus a memory read and a
conditional branch).

-- Damien
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Caml-list] C ffi issue
@ 2001-09-19  6:57 Jeff Henrikson
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Henrikson @ 2001-09-19  6:57 UTC (permalink / raw)
  To: caml-list


According to the C interface documentation, assignments to tuple members must be done with the modify(value*,value) function.
However, local variables once registered with the GC can apparently just be assigned.  If I do this instead will anything crash?

	CAMLlocal1(nontuple);
	modify(&nontuple,mydata);  // should just be nontuple=mydata;

If this is bad, is there a performance efficient way to wrap modify so that I can assign to tuple members and local variables in
the same way?  I am writing a stub generator (language module for SWIG) and due to the way that the preexisting model works, it is
desirable to have this congruency.

The alternative of course is to allocate some tuples when I don't need to so that the modify function always gets what it expects,
and then throw them away when necessary.  This may be faster anyway, but if modify works out of the box I'll definitely take that.

Thanks,


Jeff Henrikson





-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-09-19  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-19  9:55 [Caml-list] C ffi issue Damien Doligez
  -- strict thread matches above, loose matches on Subject: below --
2001-09-19  6:57 Jeff Henrikson

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 NNTP newsgroup(s).