caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Sven LUTHER <luther@dpt-info.u-strasbg.fr>
To: Pierre Weis <Pierre.Weis@inria.fr>
Cc: Chris Hecker <checker@d6.com>, caml-list@inria.fr
Subject: Re: Same label in different types, how do people solve this?
Date: Tue, 12 Dec 2000 11:02:11 +0100	[thread overview]
Message-ID: <20001212110211.A25607@lambda.u-strasbg.fr> (raw)
In-Reply-To: <200012111917.UAA18607@pauillac.inria.fr>; from Pierre.Weis@inria.fr on Mon, Dec 11, 2000 at 08:17:47PM +0100

On Mon, Dec 11, 2000 at 08:17:47PM +0100, Pierre Weis wrote:
> > >I understand that all you functional experts thinks this restriction is
> > >obvious, but for me it is more like a bug/misfeature. So this 'misfeature'
> > >should actually be stated for all us who aren't interested how types are
> > >infered in functional programming.
> > 
> 
> > I'm with Mattias on this one.  I'm practical above theoretical.  All
> >of the workarounds for this problem seem like they generate way more
> >tedious work for the programmer, and they still don't quite accomplish
> >the goal 100%.  This characteristic of doing more work and only
> >asymptotically approaching your goal is a bad taste I associate with
> >C++.
> 
> > Anyway, my "vote" would be to allow specification, with : if it's
> > possible since it's the obvious syntax, but even with @@ if
> > necessary (even though I think it's really ugly).
> > 
> > Chris
> 
> I tried a lot of more attractive alternative:
>  -- type::label but :: is already used for lists (consing).
>  -- type@label, but @ also used (append). 
>  -- type`label, but the symbol ` introduces variant
>  -- type'label (as in Ada), but ' is used in identifier and chars and ...
> 
> Another available notation could be type.:label, or type.'label ...
> 
> Cheers,
> 
> PS: I added something in the FAQ about the problem of overloading of
> labels, see one of (or both :)
> 
> http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-fra.html
> http://pauillac.inria.fr/caml/FAQ/FAQ_EXPERT-eng.html

Why not automatically produce some kind of module for every type declaration,
or at least the one that involve records and labels, but it could be usefull
also for variants.

when you type :

  type point_2d = { x:int; y:int}

it would be automatically converted to :

module Point_2d = struct
  type point_2d = { x:int; y:int}
end
open Point_2d

Then you can easily use :

let p2 = {Point_2d.x=10; Point_2d.y=10}

Sure there can be problem with module namespace conflicts, but a trick could
be found (well types are lowercases, while module are uppercases, isn't it ?)

Is there a big space or efficiency issue involved with this ?

Another idea would be to have the record cast to the correct type :

let p2 : point_2d = {x=10; y=10}
or
let p2 = {x=10; y=10} : point_2d

Or maybe this causes problems with the typer ?

Friendly,

Sven Luther



  reply	other threads:[~2000-12-14 17:44 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-06 21:22 Mattias Waldau
2000-12-07 16:49 ` John Max Skaller
2000-12-07 18:34 ` Maxence Guesdon
2000-12-07 23:02 ` Gerd Stolpmann
2000-12-08  1:22 ` Jacques Garrigue
2000-12-08  9:31   ` Sven LUTHER
2000-12-08  9:36     ` Pierre Weis
2000-12-08  9:48       ` Sven LUTHER
2000-12-08 18:41       ` John Max Skaller
2000-12-08  9:40     ` Nicolas barnier
2000-12-08 16:36 ` Brian Rogoff
2000-12-11 17:19   ` Pierre Weis
2000-12-10 12:49 ` Mattias Waldau
2000-12-11 18:23   ` Chris Hecker
2000-12-11 19:17     ` Pierre Weis
2000-12-12 10:02       ` Sven LUTHER [this message]
2000-12-12  3:25     ` Chet Murthy
2000-12-12 17:43       ` John Max Skaller
2000-12-12 19:24         ` Functions must be explicitly typed, (was Same label in different types, how do people solve this?) Mattias Waldau
2000-12-13  0:51           ` John Max Skaller
2000-12-15 10:13             ` Andreas Rossberg
2000-12-15 12:50             ` Frank Atanassow
2000-12-14 18:42           ` Stefan Monnier
2000-12-15 12:47             ` Pierre Weis
2000-12-15 13:39               ` Mattias Waldau
2000-12-15 23:37                 ` Brian Rogoff
2000-12-16 14:10                 ` ROverloading John Max Skaller
2000-12-15 21:51         ` Same label in different types, how do people solve this? Bruce Hoult
2000-12-12 17:19   ` John Max Skaller
2000-12-10 14:57 Ohad Rodeh
2000-12-13 13:17 Dave Berry
2000-12-13 14:31 ` Mattias Waldau
2000-12-15 10:01   ` John Max Skaller

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=20001212110211.A25607@lambda.u-strasbg.fr \
    --to=luther@dpt-info.u-strasbg.fr \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=checker@d6.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).