[m-dev.] Adding `.' as a module separator
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Dec 2 12:40:47 AEDT 2002
On 02-Dec-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> I've just been looking into adding `.' as a module separator.
>
> Changing the lexer to allow `.' as an embedded character in names is
> straightforward.
Why do you want to do that? Why can't you just handle it as `:' is
handled now (as an operator).
> The next step seems to be to change prog_util__string_to_sym_name to
> take a list of module separators rather than just one*.
>
> However, this approach raises the problem of what to do with quoted
> names like 'foo.__bar' and 'baz__.quux' or even 'spoo.__.fleem'.
'foo.__bar' => qualified(unqualified("foo."), "bar")
'baz__.quux' => qualified(unqualified("baz"), ".quux")
'spoo.__.fleem' => qualified(unqualified("spoo."), ".fleem")
> As I see it we have the following options:
>
> 1. change the lexer to treat infix `.' as an operator and change the
> parser to recognise `.'/2 terms as module qualified names (this will
> cause merry Hell with backwards compatibility);
Infix `.' is already recognised as an operator (you'll need to change
the associativity).
> 2. detect and report an error in these situations (although
> this may make code elsewhere more complicated);
Don't bother, the error will be reported where the symbols are used
if the parse isn't what the user expected.
> 3. parse the strings using a rule like "first split at the '.'s, then
> split the pieces at the '__'s, stragglers are deemed to be part of
> the name" (rather like the way we currently interpret 'foo____bar',
> namely as `qualified("foo", unqualified("__bar"))'). This still
> wouldn't tell us what to do in cases like 'foo..bar', although we could
> use the same rule as we currently do for '__'.
I'd argue that if it is a term constructed using '.', you shouldn't
be looking for '__' at all.
> Hmm, looking more closely at string_to_sym_name, it seems we interpret
> 'foo____bar__baz' as `qualified("foo", unqualified("__bar__baz"))' which
> is definitely confusing!
That's arguably a (very minor) bug.
'foo____bar__baz' =>
qualified("foo", (qualified(unqualified("__bar"), "baz")))
Simon.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list