[Aldor-l] [Aldor-combinat-devel] Should this "parser" work?
Martin Rubey
martin.rubey at univie.ac.at
Thu Oct 26 17:33:47 EDT 2006
Dear Christian, *,
"Christian Aistleitner" <tmgisi at gmx.at> writes:
> However, for the evaluation of Domains, you should not rely on an execution
> order.
> But your code does. And for me, this relying seems to be inherent. So once
> again, your grammar works for the current Aldor compiler. But I am not sure
> if it does for future versions of the compiler.
well, that's probably bad news. The AUG says about an expression T in
C == T add { ... }, i.e., an expression in "type context":
Type context is special in two ways:
* Expressions occurring in type context are not guaranteed to be evaluated
in any particular order, or even evaluated at all.
* Identifiers occurring in an expression, T, appearing in type context must
be constant in the scope in which T occurs.
The reason expressions in type context are not guaranteed to be evaluated in
order, or at all, is to give maximum flexibility to produce efficient
programs. A portable program will only use non-side-effecting expressions in
type context.
In the present case of the "grammar" function, I guess that the second
"speciality" -- name constancy -- is satisfied. In our case, T is
evaluate(parse(p.i), res). Am I right that "the scope in which T occurs" is
simply "evaluate(parse(p.i), res)" itself? Or is it the whole body of E? In any
case, I'd argue that "res" is not modified, only it's individual elements are.
However, "grammar" does depend on the order in which the type expressions in
the program are evaluated. It requires that "evaluate(parse(p.i), res)" is
evaluated after "res" is set.
In any case, I also think that the dependence on lazy evaluation is rather
crucial for defining that "grammar" function. On the other hand, it seems
unreasonable to me to evaluate an expression T in
C == T add { ... }
before C actually is used. Thus, do you think that it would be unreasonable to
have a future Aldor compiler have this property specified? It seems to make
Aldor rather more powerful... Unless there is a (practical) way to specify the
algorithm outlined by "grammar", of course. I think it really should be
possible, otherwise it's a deficiency of Aldor.
Christian, I'd like to send you a very big "THANK YOU" for sharing your
insights and insisting on finding the real reason.
Martin
PS: Christian, you also wrote
> To me, it fits well into my picture of Aldor. But I am not sure if that's
> good for your Aldor-Combinat project.
> Nevertheless, it's good to see your code working. It's also fine, what you
> demonstrated with all the debug output in the form of (Something pretend
> MachineInteger).
I don't really understand: you say that it's good that my code is working, and
that it first well into your picture of Aldor. Isn't that a little
contradictory to your second sentence?
Martin
More information about the Aldor-l
mailing list