From: Leo White <lpw25@cam.ac.uk>
To: Goswin von Brederlow <goswin-v-b@web.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Record field disambiguation in 4.01
Date: Tue, 12 Mar 2013 11:30:16 +0000 [thread overview]
Message-ID: <87a9q897p3.fsf@kingston.cl.cam.ac.uk> (raw)
In-Reply-To: <20130311103139.GA3683@frosties> (Goswin von Brederlow's message of "Mon, 11 Mar 2013 11:31:39 +0100")
> I think this show a problem of how types propagate only in one direction.
>
> p1 and p2 are both the same type but p1 gets infered corectly while p2
> needs the type annotation to avoid a warning. Lets look at the types:
>
> [...]
>
> It would be nice if the type inference and disambiguation would allow
> type information to flow both ways. Not just from first use to last
> but also from last use to first. Up, down, left and right in the tree
> representation of the code.
>
> Maybe the use of p2.y with .* (or in general disambiguation on the
> expected type of the label) because it could lead to hard to follow
> resolution of ambiguous record use. But the p2.x is a clear indication
> of what type the programmer wanted.
While in a way it is the opposite of what you're asking for, you can get
more consistent behaviour by using the "-principal" argument:
# let cross_product p1 p2 =
p1.x *. p2.y -. p1.y *. p2.x
;;
Characters 41-42:
p1.x *. p2.y -. p1.y *. p2.x
^
Warning 41: this use of y is ambiguous.
Characters 49-50:
p1.x *. p2.y -. p1.y *. p2.x
^
Warning 41: this use of y is ambiguous.
Regards,
Leo
next prev parent reply other threads:[~2013-03-12 11:30 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-09 23:39 Yaron Minsky
2013-03-10 1:24 ` Jacques Garrigue
2013-03-11 11:38 ` Maxence Guesdon
2013-03-12 7:57 ` Alain Frisch
2013-03-10 3:04 ` Markus Mottl
2013-03-10 9:33 ` Gabriel Scherer
2013-03-11 10:31 ` Goswin von Brederlow
2013-03-12 11:30 ` Leo White [this message]
2013-03-11 18:49 ` Yaron Minsky
2013-03-11 11:52 ` Alain Frisch
2013-03-11 18:52 ` Yaron Minsky
2013-03-12 8:05 ` Alain Frisch
2013-03-12 15:05 ` Jacques Garrigue
2013-03-12 15:29 ` Jacques Carette
2013-03-12 17:07 ` Gabriel Scherer
2013-03-12 20:42 ` Jacques Garrigue
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=87a9q897p3.fsf@kingston.cl.cam.ac.uk \
--to=lpw25@cam.ac.uk \
--cc=caml-list@inria.fr \
--cc=goswin-v-b@web.de \
/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