[Aldor-l] [Aldor-combinat-devel] Should this "parser" work?

Christian Aistleitner tmgisi at gmx.at
Sun Oct 29 04:37:28 EST 2006


Hallo,

On Sun, 29 Oct 2006 01:18:00 +0200, Ralf Hemmecke <ralf at hemmecke.de> wrote:

>> So this bit boils down to the question: what does constancy mean. In  
>> fact, AUG
>> is quite explicit here:
>>
>> The names appearing in an expression in type context may be
>>
>> * defined via "=="
>> * imported via "import", or
>> * function parameters which are nowhere updated.
>>
>> So, I guess, res.i := something is not allowed.
>
> Sounds wrong to my ears. It says, that "res:=something" is not allowed.
> "res.i:=something" doesn't change the "constant" status of "res". That
> sounds strange, but I believe that it is true in aldor.

the basic problem is rather hidden and spread across the functions grammar  
and evaluate.

Consider the following minimalistic version:

evaluate( t: ExpressionTree, selfList: List LabelSpecies: LabelSpecies == {
	...
	Times( ... selfList . 1 ... );
       ...
}

grammar( ... ): ... == {
   ...
   res := ...
   ...
   res . 1 := evaluate( ..., res );
   ...
}

res gets set.
within evaluate, res is constant. That's right.
within evaluate, res is a function parameter.
within evaluate, res is (maybe quite contradictory to the AUG) used in  
type context (via Times as selfList and later on the add within grammar).
back in the grammar, res is modified (regardsless whether it is constant  
within grammar or not).

So from evaluate's perspective, res is a function parameter in type  
context that is updated somewhere.
Hence, it contradicts “nowhere updated” of the third condition.

The crux is that res' modification (apply) is an abbreviated set! function.

> I don't remember where you started with, but I guess the code from
> aldor-combinat/trunk/combinat/src/grammar.as.nw (revision 84)
>
> grammar(p: List String): List LabelSpecies == {
>          import from MachineInteger, LabelSpecies, List LabelSpecies;
>          A: LabelSpecies == coerce EmptySetSpecies;
>          res: List LabelSpecies := [A for x in p];
>          E(i: MachineInteger)(L: LabelType): CombinatorialSpecies(L) ==
>            (coerce evaluate(parse(p.i), res))(L) add;
>          for i in 1..#p repeat res.i := coerce E(i);
>          res;
> }
>
> is quite similar to the code you gave initially. But here clearly res is
> *not* a constant, since it is defined via ":=". I've just replaced it by
> "==" and "make check" still succeeds.

res needn't be constant in grammar per se. The “:=” is perfectly valid.  
Constancy is established by passing it as parameter to the “evaluate”  
function.
Within “evaluate”, res is constant. That's good.

However, Aldor does not check modifications well enough. The fact that
res . i := ...;
modifies res is a semantic property, the compiler does not know. It cannot  
check it.

> Or has somebody received private mail from aldor.org
> concerning this issue?

I haven't.

--
Kind regards,
Christian



More information about the Aldor-l mailing list