Version française
Home     About     Download     Resources     Contact us    
Browse thread
immutable Strings?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] immutable Strings?
From: Richard Jones <rich@annexia.org>
> On Mon, Mar 14, 2005 at 12:57:28PM +0000, rich wrote:
> > You can get the s.[i] shortcut by naming your module
> > 'ImmString.String' (using a nested module in other words) and using
> > 'open ImmString'. [...]
> 
> (Replying to my own email ...)
> 
> This reminds me of another problem I was going to ask about.  Would it
> be possible to have a syntax allowing you to always get to the "top"
> of the module namespace.  It could be something like ".String.copy"
> which would always refer to the real String module, not to any
> submodule of an opened module.

First remark, there is a workaround against name hiding through open:
you can bind your original module with another name before doing open.

  module OrigString = String
  open ImmString
  ...

Not to say that the feature you suggest would be useless: there are
cases where you want to avoid ambiguities. But the above syntax
wouldn't work: in many cases the leading dot would be confused for
a selection construct.
Except for the syntax, I believe the implementation would be easy:
the original environment is always kept around in the compiler.

If you have a better idea for the syntax, register a wish with the bug
report system...

Jacques Garrigue