From: John Harrison <John.Harrison@cl.cam.ac.uk>
To: caml-list@inria.fr
Cc: John.Harrison@cl.cam.ac.uk
Subject: Re: arity of type constructors
Date: Wed, 21 May 1997 11:50:23 +0100 [thread overview]
Message-ID: <E0wU8yQ-0008Ks-00@heaton.cl.cam.ac.uk> (raw)
In-Reply-To: Your message of "Thu, 08 May 1997 22:15:23 +0200." <Pine.GSO.3.95.970508220638.26708C-100000@terreaux>
David Monniaux writes:
| If you declare type t = T of int*int, it declares a type t whose only
| constructor takes two parameters, of respective types int and int, not a
| constructor that takes one paramete of type int*int. Thus it can't be
| applied to a pair.
|
| That is reflected in the way memory objects are handled. A constructor
| that takes a pair as an argument will have the following layout:
|
| T -> pair [ int
| [ int
|
| if it has two arguments, the layout is the following:
|
| T [ int
| [ int
|
| Using a pair adds one level of indirection.
In that case, what happens during pattern-matching? For example:
> Caml Light version 0.73
#type triv = Triv of int*int;;
Type triv defined.
#let getpair = fun (Triv(p)) -> p;;
getpair : triv -> int * int = <fun>
Is this sort of definition safe? Perhaps one should use the following
to ensure a pair is reconstructed:
#let getpair = fun (Triv(a,b)) -> a,b;;
John.
next prev parent reply other threads:[~1997-05-21 13:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-05-07 13:16 Christian Lindig
1997-05-08 20:15 ` David Monniaux
1997-05-21 10:50 ` John Harrison [this message]
1997-05-21 18:46 ` Xavier Leroy
1997-05-09 5:57 ` Michel Quercia
1997-05-09 11:53 Damien Doligez
1997-05-12 7:08 Hubert Canon
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=E0wU8yQ-0008Ks-00@heaton.cl.cam.ac.uk \
--to=john.harrison@cl.cam.ac.uk \
--cc=caml-list@inria.fr \
/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