Google Groups Home
Help | Sign in
Message from discussion Type from local module would escape its scope?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Jean-Marie Gaillourdet  
View profile
 More options Jul 3 2006, 9:58 am
Newsgroups: fa.caml
From: Jean-Marie Gaillourdet <j...@gaillourdet.net>
Date: Mon, 03 Jul 2006 13:58:28 UTC
Local: Mon, Jul 3 2006 9:58 am
Subject: Re: [Caml-list] Type from local module would escape its scope?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,

On 03.07.2006, at 15:19, Bruno De Fraine wrote:

> While the following is rejected:

> let foo (ignore: 'a -> unit) =
>   let module Foo : FOO =
>   struct
>     type t = int
>     let value = 1
>   end in
>   ignore Foo.value
> ;;

> With an error on the expression "Foo.value" stating that "The type  
> constructor Foo.t would escape its scope". Reading about the  
> typical case for this error message in http://caml.inria.fr/pub/ml-
> archives/caml-list/2002/10/0cf087feab3ef8dc5ccba5a8592472fb.en.html  
> didn't really help me. Why does it make a difference whether ignore  
> is an argument?

Let us extend your example with the following code:

> let foo (ignore: 'a -> unit) =
>   let module Foo : FOO =
>   struct
>     type t = int
>     let value = 1
>   end in
>   ignore Foo.value
> ;;

let bar (ignore: 'b -> unit) =
   let module Foo : FOO =
   struct
     type t = float
     let value = 1.0
   end in
   ignore Foo.value

let baz () =
   let x = ignore in begin
     foo x;
     bar x
   end

Which type should x have?

Best Regards,
   Jean-Marie

PS: didn't compile that code

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEqR28NIUNP/I5YOgRAoRcAKDKWlxVFBKYfdmBvPJ/T2LYrwKu+ACfYJnK
LUIeev+RCMoifUFF5ZNJVK0=
=mEs/
-----END PGP SIGNATURE-----

_______________________________________________
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 to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google