[Aldor-l] How to emulate new infix and postfix operators in Aldor

Ralf Hemmecke ralf at hemmecke.de
Tue Aug 29 19:54:28 EDT 2006


> But I don't see much "syntactic sugar" here.

The syntactic sugar is that you don't *see* the "apply" function.
The compiler add "apply" for you without changing the semantics of the 
program.

 > Using _42 as an identifier just seems weird. Can you think of a 
reason to do
> that?

No. But, when I was looking for turning ! into an identifier, I found 
_33 in the AUG and so I just copied it here for demonstration. I don't 
think that I would use it unless someone tells me a nice application.

> Then we have
> 
>   sum(z:Z,w:Z):Z == z+w;
> 
>   1 2 sum = sum 1 2
> 
> Unfortunately although we can now write
> 
>   + 1 2
> 
> the over jealous compiler rejects
> 
>   1 2 +
> 
> as a syntax error (although it would seem ok to me).

Well, + is a special thing as would be all the other operators that are 
treated as "infix" operators by the language. You can explicitly turn 
them into prefix operators by putting parentheses around them.

Try

1 2 (+)

That works.

Ralf



More information about the Aldor-l mailing list