François Bobot <bo...@lri.fr> writes:

> On 24/03/2012 13:45, Wojciech Meyer wrote:
>> Please see [1], Alain Frisch has been working recently on implementing
>> in-line records for constructor arguments.
>>
>> It's more implementation/design implications than people might think.
>>
>> [1] http://caml.inria.fr/mantis/view.php?id=5528
>
> In the thread of this proposed feature, there is a remark that inlined
> record and normal record can become competing features. There is also
> the burden that inlined record as proposed can be modified only in
> pattern matching.
>
> But can't we consider that, for a semantic, syntax and typing perspective:
>
> type t =
>    | A of string
>    | B of ({msg: string; mutable foo:int} as t2)
>    | C
>
> is exactly the same thing than:
>
> type t =
>    | A of string
>    | B of t2
>    | C
>
> and t2 = {msg: string; mutable foo:int}

That would change existing code because B of t2 currently is a Block of
size 1 with tag B and pointer to a record of type t2.

> The only difference is that when you create a record of type t2 the
> tag is directly the one of B in the first case and is the default tag
> for record (the first tag if I remember well) in the second case. So
> in the first case applying the constructor B is just the identity.

Maybe the type of a record could be altered to, at least internally,
include a tag value:

type t = A of string | B of ({msg: string; mutable foo:int} as t2) | C
type t2 = {[B] x : int; }

The inline record would be identical to the external record with tag
value and (t2 :> t) would work even implicitly.

MfG
        Goswin

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to