[Aldor-l] +-> lambda expressions without specifying types
Ralf Hemmecke
ralf at hemmecke.de
Sun Mar 22 14:17:49 EDT 2009
Good point, but that only allows specification of the parameter type.
I would have to give the target type anyway.
However, also
---rhxBEGIN
#include "aldor"
default x: Integer;
default y: Integer;
foo: (Integer, Integer)->Boolean == (x, y):Boolean +-> true;
---rhxEND
is not a program that the current compiler accepts.
>aldor -fx -laldor aaa.as
"aaa.as", line 4: foo: (Integer, Integer)->Boolean == (x, y):Boolean +->
true;
.....................................^..^
[L4 C38] #1 (Error) Expecting a comma separated list of parameters.
Regards,
Ralf
On 03/22/2009 10:22 AM, Stephen Watt wrote:
> Yes, it allows that syntax, but it will not infer the types of the
> arguments. The syntax makes sense, though, because the parameter
> names may have been given a default type.
>
> -- Stephen
>
> On Fri, Mar 20, 2009 at 8:14 PM, Ralf Hemmecke <ralf at hemmecke.de> wrote:
>> If I did not make a mistake, the grammar in the Aldor User Guide seems to
>> allow something like x+->x+1.
>>
>> But in the program below the Aldor compiler (1.1.0) cannot/does not infer
>> the type of the lambda expression in baz.
>>
>> Stephen, is that intended or is that just a short-coming of the compiler?
>>
>> Ralf
>>
>> ---------------------------------------------------------
>>> aldor -fx -laldor aaa.as
>> "aaa.as", line 9: baz(i: Integer): Integer == foo((x +-> x-1), i);
>> ...................................^
>> [L9 C36] #1 (Error) Expecting a comma separated list of parameters.
>>
>> ---rhxBEGIN aaa.as
>> #include "aldor"
>> Aaa: with {
>> foo: (Integer -> Integer, Integer) -> Integer;
>> bar: Integer -> Integer;
>> bar: Integer -> Integer;
>> } == add {
>> foo(f: Integer->Integer, i: Integer): Integer == f i;
>> bar(i: Integer): Integer == foo((x: Integer): Integer +-> x+1, i);
>> baz(i: Integer): Integer == foo((x +-> x-1), i);
>> }
>> main(): () == {
>> import from String, Character, TextWriter, Integer, Aaa;
>> stdout << foo(bar, 1) << newline;
>> stdout << bar 1 << newline;
>> stdout << bar 1 << newline;
>> }
>> main();
>> ---rhxEND aaa.as
>>
More information about the Aldor-l
mailing list