Is it a bug or is it me

  • I have a class method declared with 1 argument as integer

  • calling this method without an argument compiles with NO errors

  • Reason: because I have a method Operator_Lookup and it runs into this method

  • I thought ok, why not add () at the end of the calling method to tell the compiler this is a method and not a property, even that compiled, no error

what is wrong here ?

Did you try to call it with one parameter, so Xojo can pick the method for you?

yes, it works passing an argument

forgot to say, I’m using Xojo 2020 release 2

Adding “()” makes no difference in Xojo as it might in other languages. The name of what you’re calling must be unique, or in the case of a method, must match a signature, but if a method has no parameters, you can call it with or without the parens.

You can overload a method, that is, define it with different signatures. For example:

Sub M ()
Sub M (flag As Boolean)
Sum M (index As Integer, flag As Boolean)

Which method is called depends entirely on which parameters you supply, and you may call it as simply M without any parameters.

yes Kem, but my problem is it runs into the Operator_lookup method instead of the real method when calling without an argument.

I did a copy and paste and forgot to add the argument, took Mme a while to find the problem, now I know

what I don’t know is, why does the compiler not report an error ???

Can you post an example project?

Because that’s the point of overloading the lookup operator. You’re explicitly telling the compiler that unrecognized names aren’t an error and to pass them along to your special handler method.

Operator_Lookup is a footgun for this and other reasons. Don’t use it.

1 Like

thanks to all,
Operator_lookup is handy but also dangerous, I remove it from my projects as much as I can

Thanks