maps and typedefs

Are all maps considered the same type for the purposes of function overloading?

I have
Code:
typedef float[int] vector;
typedef float[int,int] matrix;

string to_string(vector v){
 . . .
}

string to_string(matrix m){
 . . .
}

Gets me the error:
Function 'to_string( matrix )' defined multiple times (mathlib.ash, line 485)

But simply assuming I had defined it elsewhere and blocking out the one at that location merely changes the error message to:
Function 'to_string( matrix )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (test.ash, line 10)

And yes, tesh.ash imports mathlib.
 
I was wondering if there was something else in your script to account for this so I decided to see if I can replicate this bug in it's simplest form. It seems to be a mafia bug.

Code:
typedef float[int] vector;
typedef float[int,int] matrix;

string to_string(vector v){
	return "vector";
}

string to_string(matrix m){
	return "matrix";
}

void main() {
	vector ve;
	matrix ma;
	print(to_string(ve));
	print(to_string(ma));
}

produces

Code:
> call scripts\testing.ash

[COLOR="#ff0000"]Function 'to_string( matrix )' defined multiple times (testing.ash, line 8)[/COLOR]
 
According to ashref, to_string( any ) exists, I guess that would make to_string() difficult to overload by using only one parameter.

However, this isn't the cause of the problem since it happens even if you change the function name to my_to_string().

EDIT:
Doing this also causes the same problem:
PHP:
typedef item vector;
typedef location matrix;
I guess that all the typedefs are considered as the same type when defining functions.
 
Last edited:
According to ashref, to_string( any ) exists, I guess that would make to_string() difficult to overload by using only one parameter.
Nope. I have overloaded it many times with one parameter, as "any" only covers things that already exist.

I guess that all the typedefs are considered as the same type when defining functions.

This is what I was afraid of.
Oh well, matrixToString() makes a good name too... I guess.

Good news is, ref and rref are finished and that concludes my programming for the night.
 
Back
Top