caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: Brian Hurt <bhurt@janestcapital.com>
Cc: Roland Zumkeller <roland.zumkeller@gmail.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] F#
Date: Fri, 09 Mar 2007 10:07:02 +1100	[thread overview]
Message-ID: <1173395222.6613.22.camel@rosella.wigram> (raw)
In-Reply-To: <45F04DD0.5010505@janestcapital.com>

On Thu, 2007-03-08 at 12:54 -0500, Brian Hurt wrote:
> Roland Zumkeller wrote:
> 
> > Wasn't there a more or less good reason for OCaml *not* to support
> > operator overloading?
> >
> Yes.  Ocaml has modules and functors.  IMHO, any time you thing "boy, 
> it'd be really nice to use operator overloading here", you should use a 
> module and a functor instead.

Unfortunately you often cant do that easily:

* functors don't scale to separate compilation

* separate compilation doesn't support inter-unit recursion

* functors have a huge book-keeping overhead
(I mean syntactic overhead, not performance overhead)

* functors are hard to combine

The first two issues are implementation problems rather than
intrinsic to the language in the abstract.

The book-keeping problem is a consequence of the fine grained
control functors provide, compared with say Haskell typeclasses.

The combination problem is best characterized by an expert.

A lot of the time you want a data functor, not a module
functor, and higher order data functors (functorial
polymorphism) aren't available in Ocaml.

For example if you have some container you just want
to fold over it, which means you want a polyadic fold.
Module functors help *define* a fold which is polymorphic
over signature arguments, but don't provide polyadic usage.

Although the mechanism used in C++ is unsound, C++ 
does provide polyadic programming, and in that sense
is way ahead of Ocaml and Haskell. Despite the unsoundness,
generics in C++ usually 'just work anyhow'.

However .. and Harrop "interactive" crowd note .. functors
do provide one advantage. Because of the mandatory
book-keeping they're amenable to use of a Form based GUI/IDE
to assist in definition:

	Functor Hashtbl
	key		| <instantiating type here>
	compare         | < defn here>
	hash            | <defn here>


[That's supposed to be a form where the signature is listed in
a column format, and the programmer just fills in the
definitions]

I would probably hate that BUT it would sure help noobs learn
to use first order functors.

In fact you could use a little cheat .. and call them 
static classes, and tell people it's an Ocaml kind of OO .. 
(Haskell does this little cheat .. it makes typeclasses
very easy to explain to OO people).


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  parent reply	other threads:[~2007-03-08 23:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-08 14:41 Robert Fischer
2007-03-08 15:10 ` Jon Harrop
2007-03-08 17:30   ` Roland Zumkeller
2007-03-08 17:54     ` Brian Hurt
2007-03-08 19:40       ` [Caml-list] Operator overloading Jon Harrop
2007-03-08 20:44         ` Brian Hurt
2007-03-08 22:24         ` Fernando Alegre
2007-03-08 23:07       ` skaller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-03-08  1:13 Interactive technical computing Jon Harrop
2007-03-08  2:12 ` [Caml-list] " Erik de Castro Lopo
2007-03-08 12:41   ` [Caml-list] F# Jon Harrop
2002-06-10 14:04 Don Syme
     [not found] <BCDB2C3F59F5744EBE37C715D66E779C0481E208@red-msg-04.redmon d.corp.microsoft.com>
2002-06-09 17:49 ` Chris Hecker
2002-06-09 12:26 Don Syme
2002-06-10  6:22 ` Michael Vanier
     [not found] <BCDB2C3F59F5744EBE37C715D66E779C0481E206@red-msg-04.redmon d.corp.microsoft.com>
2002-06-09  1:30 ` Chris Hecker
2002-06-08 23:04 Don Syme
2002-06-08 15:05 Vincent Foley
2002-06-08 16:01 ` Xavier Leroy

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=1173395222.6613.22.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=bhurt@janestcapital.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=roland.zumkeller@gmail.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).