Re: [Caml-list] using modules to wrap c++ classes

2012-05-05 Thread Goswin von Brederlow
Joel Reymont joe...@gmail.com writes: On Fri, May 4, 2012 at 9:43 AM, Goswin von Brederlow goswin-...@web.de wrote: As discussed on irc you need to create your callbacks[] array as ocaml block and register that itself as root. That also has the benefit that you only have to register a

[Caml-list] A shallow option type

2012-05-05 Thread Goswin von Brederlow
Hi, I wish there was an option type that would work without extra indirection (or more importantly without extra allocation of an ocaml value when setting it to something). Why? I'm interfacing with C in a multithreaded way. The data is allocated on the C side so it won't be moved around by the

Re: [Caml-list] A shallow option type

2012-05-05 Thread Gabriel Scherer
Is it possible to somehow declare the constraint that 'a in 'a shallow must not be itself a 'b shallow? If I understand correctly, this is not possible directly, and while you could do that with a sufficiently clever layer of phantom types, I'm not sure it is worth the additional complexity. In

Re: [Caml-list] using modules to wrap c++ classes

2012-05-05 Thread Joel Reymont
On Sat, May 5, 2012 at 1:39 PM, Goswin von Brederlow goswin-...@web.de wrote: Don't you have to use caml_modify() here instead of Store_field()? I think Store_field is only alowed in freshly allocated blocks. Store_field uses caml_modify behind the scenes. /* convenience macro */ #define

Re: [Caml-list] A shallow option type

2012-05-05 Thread Andreas Rossberg
On May 5, 2012, at 15.33 h, Goswin von Brederlow wrote: What I want is a type 'a shallow = NULL | 'a (constraint 'a != 'b shallow) This is a form of negation, which cannot be expressed in conventional type systems. Just consider what it should mean in the presence of type abstraction:

[Caml-list] How do I declare a value of 'a t instead of '_a t in a module?

2012-05-05 Thread Goswin von Brederlow
Hi, I'm writing a module that reimplements the option type without redirection. For that I'm mapping None to a value with all bits set to 0, the NULL pointer in C. For that I have a little helper function: external make_null : unit - 'a t = caml_shallow_null But now I want to also have a

Re: [Caml-list] How do I declare a value of 'a t instead of '_a t in a module?

2012-05-05 Thread Gabriel Scherer
You need to specify in the signature that ('a t) is contravariant: type +'a t This is done to please the relaxed value restriction: in the let-binding let foo = make_null (), the right-hand-side is not a value, so it is not generalized (this is the value restriction). The relaxation introduced

Re: [Caml-list] A shallow option type

2012-05-05 Thread Goswin von Brederlow
Andreas Rossberg rossb...@mpi-sws.org writes: On May 5, 2012, at 15.33 h, Goswin von Brederlow wrote: What I want is a type 'a shallow = NULL | 'a (constraint 'a != 'b shallow) This is a form of negation, which cannot be expressed in conventional type systems. Just consider what it

Re: [Caml-list] A shallow option type

2012-05-05 Thread Gabriel Scherer
Thanks for the clearer use-case example. I think Andreas's comment is at a general level of language design: no, we don't want to add something close to what you're asking for in a language. His argumentation is spot on. What we could have is a type system with strong update, but that's dreaming

[Caml-list] CiE 2012: Turing Centenary Conference, Cambridge - Final Call for Presentations

2012-05-05 Thread S B Cooper
** FINAL CALL FOR INFORMAL PRESENTATIONS - DEADLINE MAY 11th, 2012: TURING CENTENARY CONFERENCE http://www.cie2012.eu Computability in Europe 2012: How the World Computes