Just for the record...

---rhxBEGIN paren.as
#include "aldor"
#include "aldorio"
I ==> MachineInteger;
main(): () == {
    import from I, List I, List List I;
    ll: List List I := [[1,2,3],[4,5,6],[7,8,9]];
    a := first ll.2;
    b := first (ll).2;
    c := first(ll).3;
    stdout << "a = " << a << newline;
    stdout << "b = " << b << newline;
    stdout << "c = " << c << newline;
}
main()
---rhxEnd paren.as

aldor -laldor -fx paren.as
./paren
a = 4
b = 2
c = 3

Looks like parens force precedence of prefix function application over the dot application.

I think, like in Fortress where

  a+b * c

leads to an error because the spacing might be misleading for humans, there should also be a warning (at least) in cases a and b.

Even case c is only clear if one knows just one language. But with all the different languages around, it's like *int[], where a non-native C programmer constantly has to look up precedence rules.

Ralf


On 01/06/2012 10:12 PM, Waldek Hebisch wrote:
Ralf Hemmecke wrote:

I took a quick look for other suspicious cases of ). in the boot code.
I found this one:

+411 src/interp/category.boot

        PrinAncb:= first(b).(4)

This is probably correct but it seems crazy to write it this way if
you really mean

        PrinAncb:= first(b.4)

Sometimes you really have to wonder what they were smoking back in the
lab ... ;)

Interesting

PrinAncb:= first(b).(4)

gives

with bootsys
    (SETQ |PrinAncb| (CAR (ELT (|CatEval| |bname|) 4)))

with depsys
   (SPADLET |PrinAncb| (CAR (ELT (|CatEval| |bname|) 4)))

Why is it basically the same here and makes a difference for "CAR(d).1".
I'm a bit confused now.


Well, with depsys:

PrinAncb:= first(b).(4)

gives

(SPADLET |PrinAncb| (ELT (CAR |b|) 4))

while

PrinAncb:= first (b).(4)

gives

(SPADLET |PrinAncb| (CAR (ELT |b| 4)))

Namely, precedence depends on presence or absence of space: without
space application have higher precence than ., with space lower.

BTW: NAG version was:

PrinAncb:= first (CatEval bname).(4)

Later I noticed that we can just use 'b' instead of 'CatEval bname'
so I replaced it by

PrinAncb:= first (b).(4)

For uniform look I changed this to:

PrinAncb:= first(b).(4)

but otherwise I did not look to much at this.  The change was
after switch to Shoe, so both versions had the same effect.

I must say that for me this example show how bad is practice
of ommiting parenthesis in function call with single argument
(note that with mandatory parenthesis there would be no question
of precedence -- call would always have higher precedence than '.').


--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to