This bug report demonstrates a problem with parameterless functions.
The following piece of code
#lang algol60
begin
integer procedure getvalue;
getvalue := 4;
integer i;
i := getvalue;
printnln(i)
end
fails with this message:
bad value: expected a number, got #<procedure:getvalue>
In my understanding, the problem is that in
i := getvalue;
the function getvalue is not called. Instead, the generated code attempts to assign a function to an integer, which of course fails.
The following modified example works:
#lang algol60
begin
integer procedure getvalue(arg);
Boolean arg;
getvalue := 4;
integer i;
i := getvalue(true);
printnln(i)
end
This works because the call of a function with parameters is unambiguous.
To further clarify the more tricky aspects of parameterless functions, consider the following example:
#lang algol60
begin
real procedure r;
begin
r := 5.0;
end;
real procedure p1(rv, rp);
real rv;
real procedure rp;
begin
p1 := rv + rp
end;
printnln(p1(r, r))
end
In Racket Algol 60 this does not work. Note that in the expression
p1(r, r)
the first occurance of r is a function call, while the second isn't. For some reason, Racket Algol 60 does not see the difference because r is parameterless.
Again, the introduction of a dummy parameter (to function r) disambiguates a function call from a reference to a function:
#lang algol60
begin
real procedure r(x);
Boolean x;
begin
r := 5.0;
end;
real procedure p1(rv, rp);
real rv;
real procedure rp;
begin
p1 := rv + rp(true)
end;
printnln(p1(r(true), r))
end
Now a function call requires a syntax that is different from a function reference and everything is fine.
This bug report demonstrates a problem with parameterless functions.
The following piece of code
fails with this message:
bad value: expected a number, got #<procedure:getvalue>
In my understanding, the problem is that ini := getvalue;
the function getvalue is not called. Instead, the generated code attempts to assign a function to an integer, which of course fails. The following modified example works:
This works because the call of a function with parameters is unambiguous.
To further clarify the more tricky aspects of parameterless functions, consider the following example:
In Racket Algol 60 this does not work. Note that in the expression p1(r, r) the first occurance of r is a function call, while the second isn't. For some reason, Racket Algol 60 does not see the difference because r is parameterless.
Again, the introduction of a dummy parameter (to function r) disambiguates a function call from a reference to a function:
Now a function call requires a syntax that is different from a function reference and everything is fine.