After taking a closer look at the code, it appears my case changes were 
still in place. Setting it to a handle does indeed work, thanks for the 
help, and sorry for being that obtuse.

--------------------------------------------------
From: "Aaron Baker" <theultimatemasterofarc...@gmail.com>
Sent: Thursday, February 18, 2016 8:20
To: "Gamers Discussion list" <gamers@audyssey.org>
Subject: Re: [Audyssey] bgt operator overloading question

Hello,
Did you actually try it? I know that that can make the difference
between runtime error and no runtime error. I thought it was kind of
odd too, but it is usually bad practice to pass an object by value
anyway. If you're worried about the object changing, you might be able
to write it as "const stat@ other".
I really think that is the problem.
This code gives me a runtime error:
"
class stat
{
int percent;
int opCmp(stat other)
{
return percent-other.percent;
}
}
stat[] stats;
void main()
{
stats.sort_descending();
}
"

And this code doesn't:
"
class stat
{
int percent;
int opCmp(stat@ other)
{
return percent-other.percent;
}
}
stat[] stats;
void main()
{
stats.sort_descending();
}
"
Best,
Aaron

On 2/18/16, john <jpcarnemo...@gmail.com> wrote:
> Seems to be a nogo.
> I'd be surprised if that was the issue; handles are close enough to 
> objects
>
> for it to not matter as function parameters in my experience.
>
> --------------------------------------------------
> From: "Aaron Baker" <theultimatemasterofarc...@gmail.com>
> Sent: Wednesday, February 17, 2016 19:51
> To: "Gamers Discussion list" <gamers@audyssey.org>
> Subject: Re: [Audyssey] bgt operator overloading question
>
> Hey John,
> Try switching your parameter from "stat other" to "stat@ other".
> I think opCmp wants a handle (by reference), not a by value object.
> Best,
> Aaron
>
> On 2/17/16, john <jpcarnemo...@gmail.com> wrote:
>> Hi all,
>> I'm attempting to overload comparison operators in order to sort an array
>>
>> of
>> objects, with the following function:
>> //begin code
>> int opCmp (stat other)
>> {
>> return percent-other.percent;
>> }
>> //end code
>> However, the program gives me the following error as soon as comparison
>> takes place:
>> A runtime error occurred. File:function: void main()Description: Type
>> 'stat'
>> does not have a matching opCmp method
>>
>>
>>
>> Can anybody shed some light on this one?
>>
>>
>>
>> Thanks,
>>
>> John
>>
>>
>>
>> P.S:
>>
>> Yes, the comparison function is within the stat class, and comparison is
>> being done by array.sort_descending.
>>
>> I have tried several case changes to the function name, and have stuck
>> with
>> the above because it matches both the manual and compiler error.
>> ---
>> Gamers mailing list __ Gamers@audyssey.org
>> If you want to leave the list, send E-mail to
>> gamers-unsubscr...@audyssey.org.
>> You can make changes or update your subscription via the web, at
>> http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
>> All messages are archived and can be searched and read at
>> http://www.mail-archive.com/gamers@audyssey.org.
>> If you have any questions or concerns regarding the management of the
>> list,
>> please send E-mail to gamers-ow...@audyssey.org.
>>
>
> ---
> Gamers mailing list __ Gamers@audyssey.org
> If you want to leave the list, send E-mail to
> gamers-unsubscr...@audyssey.org.
> You can make changes or update your subscription via the web, at
> http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
> All messages are archived and can be searched and read at
> http://www.mail-archive.com/gamers@audyssey.org.
> If you have any questions or concerns regarding the management of the 
> list,
> please send E-mail to gamers-ow...@audyssey.org.
>
>
> ---
> Gamers mailing list __ Gamers@audyssey.org
> If you want to leave the list, send E-mail to
> gamers-unsubscr...@audyssey.org.
> You can make changes or update your subscription via the web, at
> http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
> All messages are archived and can be searched and read at
> http://www.mail-archive.com/gamers@audyssey.org.
> If you have any questions or concerns regarding the management of the 
> list,
> please send E-mail to gamers-ow...@audyssey.org.
>

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to 
gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org. 


---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to