Lasso Soft Inc. > Home

RhinoTrac

LassoSoft Ticket Tracking System

NOTE: If you are using Lasso Server 9.3 please Log your ticket directly via the LUX admin as this will give us more information about your issue.

Lasso 9 Issues



Ticket #7571: Have rest-only signatures act as catchall

Reported by:
Bil Corry
Date:
26 Aug, 2013
Priority:
minor
Component:
Lasso 9
Version:
9.2
Keywords:
Platform:
The following returns an error:

`Error Msg: Definition Not Found: max(integer, integer, integer, integer, integer, integer, integer, integer) Candidates were: max(lhs, rhs), max(...)`

Here’s the code:

define max(...)::integer => {

local(max) = #rest->get(1);loop(#rest->size);
#rest->get(loop_count) > #max ? #max = #rest->get(loop_count);
/loop;return(#max)

}
max(1,2,3,1,10,2,66,3);

If you change the name to “max2” it works correctly.

----
Yes, this is a known issue when defining conflicting methods where a pure rest method is involved.

The definition that you seek, which does not conflict, would be:

`define max(a, b, c, ...)`

That will differentiate it from max(a,b) by the requirement of at least three parameters.

Once the bug at hand is fixed, you will get an error defining the max(...) method as it is ambiguous.

-Kyle

----
Good to know, thanks. I was thinking the pure rest signature was a catchall after all other signatures failed to match, vs. a peer signature that competes with overlapping signatures.

Consider this a feature request then to adjust the dispatch logic to instead treat a pure rest signature as a final catchall when all other signatures have failed to match. I don't think this change will impact existing functionality/compatibility and makes the language a bit more flexible. It may make dispatch slightly slower since there's now two steps to evaluating a signature. I leave it to you to decide, but it would have been easier if it worked in this manner.

Anyhow, this seems to work if I want to overwrite the built-in type entirely, otherwise, I have to add the extra c param:

define max(a, b, ...) => {
local(max) = #a;
#b > #max ? #max = #b;
#rest->type == 'void' ? return(#max);
loop(#rest->size);
#rest->get(loop_count) > #max ? #max = #rest->get(loop_count);
/loop;
return(#max);
}

max(1,2);' ';
max(1,2,3);' ';
max(1,2,3,4);' ';
max(1,2,3,4,5);' ';
max(1.5,2.5,3.5);' ';

Comments

26 Sep, 2013 by Ke Carlton
Here's a cleaner more robust implementation:

define max(a, b, ...) => {
local(max)
params->foreach => {#1 > #max ? #max = #1}
return #1
}
Please log in to your LassoSoft account to comment

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft