Hi all,

I pushed a language change today that a few people have asked for.
Basically, if you reference a word which is available in more than one
vocabulary, you will get an error. Formerly, the order of vocabularies
in the USING: list would matter, with latter vocabularies taking
precedence for name resolution. Now, the order does not matter, and
ambiguities must be resolved by using FROM:, QUALIFIED:, or one of the
other fancy parsing words.

Note that you only have to resolve ambiguities for words you actually
reference. So if you import, say, vocabs.parser and binary-search, but
don't reference the 'search' word that occurs in both, there is no
additional boilerplate. On the other hand, if you do want to call
'search', you have to tell the parser which 'search' you want, with
one of the following two lines;

FROM: binary-search => search ;
FROM: vocabs.parser => search ;

In the case of FROM:, QUALIFIED:, and so on, the order does matter,
and the behavior is the same as before; latter declarations take
precedence and are searched first.

The rationale for this change is as follows. When you say 'USE: foo',
you are doing an "open import", in the sense that the author of the
'foo' vocabulary might add new words later on, and these words will
affect the identifier resolution of your vocabulary. So if you would
have code like so,

USING: foo bar ;

... baz ...

Where you were using the 'baz' word from the 'foo' vocabulary, and
then the developer of 'bar' decides to add an unrelated word named
'baz', your code would break because suddenly it would refer to the
wrong 'baz'. Long debugging sessions would result. If the USING: list
was in the other order,

USING: bar foo ;

Everything would continue to work because it would still resolve baz
in foo. So basically with the old way, there was a chance your code
would continue to work and a chance it would silently fail. Now, it is
an error, which is perhaps a bit more annoying in the case where the
parser would've done the right thing, but infinitely more useful in
the other case since you are instantly notified of the potential name
clash and you have to take action to resolve it.

For "closed imports" which only introduce a fixed set of names into
scope (such as FROM: or RENAME:), or introduce qualified names (such
as QUALIFIED:) there is no problem because the programmer is fully in
control over what names are available, so the old behavior, where the
ordering resolves ambiguity, is preserved.

Also, "closed imports" always take precedence over "open imports".

The only change you will have to make to existing code is add a FROM:
here or there to tell the parser which word to use in ambiguous cases.

Slava

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to