From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
Cc: ygrek <ygrekheretix@gmail.com>, caml-list@inria.fr
Subject: AW: [Caml-list] module alias inside class
Date: Wed, 03 Jul 2013 12:56:08 +0200 [thread overview]
Message-ID: <1372848968.3769.6@samsung> (raw)
In-Reply-To: <16D5DC66-9420-4B6F-B7CF-DF16161D2A6A@math.nagoya-u.ac.jp> (from garrigue@math.nagoya-u.ac.jp on Wed Jul 3 07:09:49 2013)
Am 03.07.2013 07:09:49 schrieb(en) Jacques Garrigue:
> On 2013/07/03, at 0:09, ygrek <ygrekheretix@gmail.com> wrote:
>
> > Dear list,
> >
> > Just a short question tonight, why is the following code rejected?
> >
> > class z = let module A = String in object end;;
> >
> > Is there some deep reason or it was simply overlooked?
>
>
> This would be very nice to able to do that.
> Unfortunately, the typing of classes is a rather complex process,
> which seems difficult to integrate with local module definitions,
> except maybe in a very restrictive way.
> There are also deep questions, such as what to do in presence
> of inheritance.
I guess the main problem is that types from A wouldn't be allowed to
appear in class types (type escapes definition scope) - unless the
notion of class types were extended so that such modules are bound
(e.g. class type z = object method foo : A.t end with module A :
TYPE_OF_A). But that mixes classes with modules conceptually (well, not
that we have that already).
Just trying:
# class x =
let s = (module String : Set.OrderedType) in
object
method compare = let module S = (val s) in S.compare
end;;
Error: This expression has type S.t -> S.t -> int
but an expression was expected of type S.t -> S.t -> int
The type constructor S.t would escape its scope
Gerd
>
> On the other hand, "let open" would be much easier to add.
> Jacques Garrigue
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>
--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de
Creator of GODI and camlcity.org.
Contact details: http://www.camlcity.org/contact.html
Company homepage: http://www.gerd-stolpmann.de
------------------------------------------------------------
prev parent reply other threads:[~2013-07-03 10:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 15:09 ygrek
2013-07-03 5:09 ` Jacques Garrigue
2013-07-03 10:56 ` Gerd Stolpmann [this message]
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=1372848968.3769.6@samsung \
--to=info@gerd-stolpmann.de \
--cc=caml-list@inria.fr \
--cc=garrigue@math.nagoya-u.ac.jp \
--cc=ygrekheretix@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