caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Simon Peyton-Jones <simonpj@microsoft.com>
To: "'Pierre Weis'" <Pierre.Weis@inria.fr>, dmcclain@azstarnet.com
Cc: caml-list@inria.fr
Subject: RE: Compiler translation of array indexing
Date: Wed, 19 Jan 2000 09:33:27 -0800	[thread overview]
Message-ID: <7CD674FF54FBD21181D800805F57CD54821B89@RED-MSG-44> (raw)

| > Instead of translating as in OCAML to Array.get and
| > Array.set, they could be translated into some equivalent to
| > 
| > x.(n)  ->  module_of(type_of x).get(x, n)
| 
| There are strong theoretical difficulties to obtain a type_of function
| embedded into a statically & strongly type checked language such as
| Caml. 

It's perhaps worth mentioning that one way of achieving
this effect is to use type-driven overloading, as Haskell
does.  One could say

	class Array a where
	  (.) :: a elt -> Int -> elt
	  ... more operations...

(Here 'a' is a type variable ranging over type constructors
of kind *->*.)

Now for each type (constructor) T that you want to make an
instance of Array, you would say

	instance Array T where
	  (.) = ...your implemention of indexing for T...


Such type classes are, however, fully implemented in Haskell.  
However, type classes (not to be confused with object oriented
classes as in OCaml) form quite a large design space, and its
interaction with OCaml classes and modules are quite unknown (to me
anyway).  


There's a paper about the type-class design space at
	http://research.microsoft.com/~simonpj/papers/multi.ps.gz

Simon




             reply	other threads:[~2000-01-19 20:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-19 17:33 Simon Peyton-Jones [this message]
2000-01-19 22:50 ` Pierre Weis
2000-01-24 17:06   ` Andreas Rossberg
  -- strict thread matches above, loose matches on Subject: below --
2000-01-18 16:34 David McClain
2000-01-19 14:25 ` Pierre Weis
2000-01-19 17:08   ` Markus Mottl
2000-01-19 21:17     ` Pierre Weis

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=7CD674FF54FBD21181D800805F57CD54821B89@RED-MSG-44 \
    --to=simonpj@microsoft.com \
    --cc=Pierre.Weis@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=dmcclain@azstarnet.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).