On 10.11.14 22.02, Öö Tiib wrote:
> Ok, but on case the outer scope names are hidden ... why
> to keep them also in lookup table within scope?
>
> Lets say scope 7 declares name "a", and there are no names
> that it hides. You can add name "a" to lookup table and
> memorize to remove it at end of scope 7.
>
> Then scope 7 declares name "b", and there is already name
> "b" from scope 5 that it hides. You can modify name "b"
> in lookup table and memorize to restore the scope 5 "b"
> to power at end of scope 7.
This was my first idea, too. But I dropped it because it makes the code
for modification on the lookup table somewhat complicated.
Symbols could be legally redefined in the same scope. It is only one of
my extensions to protect symbols against redefinition inside the same
(maybe global) scope. In this case I must not put the current symbol
value into the recovery container, of course.
> If the nesting of scopes is straight (unlike with
> classes, namespaces and ADL) then it must be is
> even more simple. I see no reason why you should
> have so complex, multi-layer lookup table on that case.
Hmm, maybe I should rethink about the above approach.
> For assembler it likely does not matter. Assembler
> presumably does not preprocess into million line monsters
> like C++.
No, obviously not. The expansion factor is only in the order of 2 to 4.
I.e. 1 line of source emits 2 to 4 instructions depending on whether you
count comment lines as well or not.
> However ... simplicity is also quality on its
> own.
Indeed.
> Why you should do several lookups?
It is simply easier to implement. Each level start with its own empty
dictionary. Each modifying directive applies to the deepmost dictionary
for local operations or on the outermost dictionary for global changes.
At the end of the scope I simply do a pop_back and the previous state is
restored with exception of the global changes.
From the code's point of view there are several locations where the
dictionaries are modified with different directives. But there is only
one read access: the instruction parser for macros and the expression
parser for anything else.
> Is there some
> diagnostic about defects that you want to improve
> somehow with it?
I think printing meaningful diagnostic messages is easily possible with
any of the discussed data models.
Marcel