Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Gordon Henriksen <gordonhenriksen@mac.com>
To: "caml-list@yquem.inria.fr" <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] "OCaml gives you only monomorphic methods in classes."
Date: Fri, 28 Dec 2007 18:19:53 -0700	[thread overview]
Message-ID: <1A5E39DC-CCAE-48B2-AC06-C671143A6C50@mac.com> (raw)
In-Reply-To: <200712290027.26471.jon@ffconsultancy.com>

Oh, were you proposing a language feature? In that case, consider:

let bar x = foo x

How to compile that?

- Gordon

On Dec 28, 2007, at 17:27, Jon Harrop <jon@ffconsultancy.com> wrote:

> On Friday 28 December 2007 23:55:32 Gordon Henriksen wrote:
>> Jon, consider the case of Java or C++ method (and function)
>> overloading. This form of static dispatch is quite distinct from
>> virtual method dispatch, and is indeed at odds with type inference.
>
> I see. Still, the solution seems easy enough. Just treat the  
> overloaded types
> as part of the function name:
>
>  foo(int n)
>  foo(float x)
>  foo(string s)
>
> becomes:
>
>  foo_int n
>  foo_float x
>  foo_string s
>
> When you come across:
>
>  foo(a)
>
> you look up the statically inferred type of "a" and just bail if it  
> fails to
> match any of the overloads.
>
> Generics are left alone:
>
>  foo<T>(T x)
>
> becomes:
>
>  foo (x : 'T)
>
> Would that work?
>
> -- 
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> http://www.ffconsultancy.com/products/?e
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


  reply	other threads:[~2007-12-29  1:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-28 23:37 Jon Harrop
2007-12-28 23:55 ` [Caml-list] " Gordon Henriksen
2007-12-29  0:27   ` Jon Harrop
2007-12-29  1:19     ` Gordon Henriksen [this message]
2007-12-29  1:30       ` Jon Harrop
2007-12-31 14:02       ` Kuba Ober
2007-12-29  4:31 ` Dylan William Hardison
2007-12-29  7:09   ` Jon Harrop
2007-12-29  6:30 ` brogoff
2007-12-29  7:11   ` Jon Harrop
2007-12-29 16:57     ` brogoff
2008-01-08  2:30     ` Jacques Garrigue
2008-01-08  9:42       ` Jon Harrop
2008-01-08 13:45         ` Peng Zang
2008-01-08 17:29         ` brogoff
2008-01-08 21:25         ` Paolo Donadeo

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=1A5E39DC-CCAE-48B2-AC06-C671143A6C50@mac.com \
    --to=gordonhenriksen@mac.com \
    --cc=caml-list@yquem.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