Structures & operator_convert

Not sure where the idea you could use extends to add an operator_convert came from but you cannot

see Operator Overloading - Xojo Documentation
where it explicitly says

The function of mathematical operators can be changed. This is called operator overloading.


You can add these methods on classes to override operator support:

And in the new docs

##Operator overloading##
You can easily overload methods on a class, but how do you overload an operator on a class?

Xojo is good at making promises which are not satisfied by the premises…

Not sure how this comment applies ?

OPERATORS can be overloaded - in CLASSES
Which is where you define the OPERATOR_xxxxxx methods

Structures dont have methods as part of their definition
So they dont get treated the same as far as operator_xxxxx methods are concerned

Extends isnt a way to overload an operator

NOW could it be ?
I suppose there might be some changes they could make to the language that would enable this but I dont see it happening since they really haven’t touched the language* in any way in years except to make VAR and DIM behave the same

*I know Geoff would contest this BUT “the framework” is not “the language”
If it were part of the language itself then XojoScript & IDEScript would support all the new things in String, Double, and others like Fromxxxx etc
But they dont because its in the framework NOT the language and XojoScript does NOT use the same framework

Not sure if everyone at Xojo Inc knows the difference.

Unfortunately I agree

uh how about “user defined type” ?

and these can be VALUE types OR reference types

structures are value types (or behave like them)
you dont need to use NEW to create one

classes you define are reference types
basically is you use NEW to create a new instance they are reference types

1 Like