caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Alain Frisch <alain@frisch.fr>
Cc: Caml List <caml-list@inria.fr>, Jeremy Yallop <yallop@gmail.com>
Subject: Re: [Caml-list] segfault in simple program with 4.02 native
Date: Sun, 14 Sep 2014 00:41:17 -0700	[thread overview]
Message-ID: <5415469D.8050604@ens-lyon.org> (raw)
In-Reply-To: <54141BCF.60801@ens-lyon.org>

On 09/13/2014 03:26 AM, Martin Jambon wrote:
> On Sun 07 Sep 2014 06:28:34 PM PDT, Martin Jambon wrote:
>> On Sun 07 Sep 2014 11:47:43 AM PDT, Alain Frisch wrote:
>>> On 9/6/2014 7:51 AM, Martin Jambon wrote:
>>>> Thanks for the explanation, Jeremy. I guess atdgen will have to use
>>>> "option refs" after all unless someone has a better idea.
>>>
>>> I might be missing some context, but the current code seems to playing
>>> two different tricks with the type system:  using (Obj.magic 0.) as a
>>> dummy initial default value (to avoid references) and mutating
>>> normally immutable fields with Obj.set_field.  Is that right?
>>
>> Yes, exactly.
>>
>>>  You
>>> might be able to keep the first trick, but storing the values in local
>>> references instead of field of the the target record (if those
>>> references don't espace from the function, they will be represented as
>>> local mutable variables, whose mutation might actually be more
>>> efficient than those of the record fields),  building the target
>>> record at the end by reading from those references.
>>
>> Christophe Troestler also suggested this solution in a private reply.
>> I was afraid of the cost of the refs, so it's great to know that
>> they're optimized away.
>
> I think we now have a working implementation for json readers in atdgen
> (https://github.com/mjambon/atdgen/tree/fix-magic-ocaml402).
>
> However, atdgen also supports a binary format called biniou (Intro:
> http://mjambon.com/biniou.html Spec:
> https://github.com/mjambon/biniou/blob/master/biniou-format.txt). It is
> broken for the same reason as the JSON readers, but it is trickier to
> fix. Biniou allows sharing records and cyclic data. So far readers have
> been working by first creating a record with uninitialized fields, and
> then by proceeding with reading the field values. If a reference to the
> record is found, we just use the record that we already created, even if
> some of its fields are still unset.
>
> The problem here is that we need to create the record before reading its
> fields. Perhaps we could use the solution proposed by Milan Stanojević
> earlier in this thread, consisting in creating a private record type
> with mutable fields and at the end convert it to the normal type using
> Obj.magic.
>
> ... Or we could just drop support for some features, hence the following
> questions:
>
> 1. Does anyone use biniou at all?
> 2. Does anyone use biniou with cyclic data?

atdgen 1.4.0 is out (soon in opam). It should work with OCaml 4.02 for 
both json and biniou.

I dropped support for sharing, so no more support for serialization of 
cyclic data using biniou.


Martin


  reply	other threads:[~2014-09-14  7:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-05 21:33 Ashish Agarwal
2014-09-05 21:50 ` Andy Ray
2014-09-05 21:56 ` Richard W.M. Jones
2014-09-05 22:01   ` Sebastien Mondet
2014-09-05 22:06   ` Ashish Agarwal
2014-09-05 22:13     ` Richard W.M. Jones
2014-09-05 22:18       ` Richard W.M. Jones
2014-09-05 22:36         ` Török Edwin
2014-09-05 22:39         ` Martin Jambon
2014-09-05 23:39           ` Ashish Agarwal
2014-09-05 23:59             ` Martin Jambon
2014-09-06  0:12           ` Jeremy Yallop
2014-09-06  5:51             ` Martin Jambon
2014-09-06  6:00               ` Milan Stanojević
2014-09-06  7:46                 ` Frédéric Bour
2014-09-06 19:15                   ` Martin Jambon
2014-09-06 19:08                 ` Martin Jambon
2014-09-06 20:31                   ` David MENTRÉ
2014-09-06 21:57                     ` Martin Jambon
2014-09-07  7:34                       ` David MENTRÉ
2014-09-07 18:47               ` Alain Frisch
2014-09-08  1:28                 ` Martin Jambon
2014-09-13 10:26                   ` Martin Jambon
2014-09-14  7:41                     ` Martin Jambon [this message]
2014-09-05 22:18       ` Christoph Höger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5415469D.8050604@ens-lyon.org \
    --to=martin.jambon@ens-lyon.org \
    --cc=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=yallop@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).