Question: what are the rules for naming object methods?

As I am playing with Maple object to understand it better, I found strange thing.

I have simple object with 2 methods. Both are exported so they could be called from outside.

One method is called set_name and this one is called OK (I have print inside to print it is called). The next exported method is called process and when calling this method, the print never shows up. Which means it is not called. Using the same exact call.

When changing the name from process to something else, say processX now the print show, meaning the method is now called.

Is there restriction on what one can call their object method? And why would there be ?

Here is an example

restart;
module car_class()
      option object;
      local name::string:=""; 

      export process::static := proc(o::car_class)
             print("process method");             
      end proc:   

      export set_name::static := proc(o::car_class,_name::string)
             print("inside set name"); 
             o:-name := _name:
      end proc:     
end module:

my_car:=Object(car_class):  #make object

set_name(my_car,"toyota"):
process(my_car):
set_name(my_car,"toyota"):

On the screen, it only shows 

Now I changed it to 

restart;
module car_class()
      option object;
      local name::string:=""; 

      export processX::static := proc(o::car_class)
             print("process method");             
      end proc:   

      export set_name::static := proc(o::car_class,_name::string)
             print("inside set name"); 
             o:-name := _name:
      end proc:     
end module:

my_car:=Object(car_class):
set_name(my_car,"toyota"):
processX(my_car):
set_name(my_car,"toyota"):

And now on the screen it shows OK

Is there a way a way to be able to freely choose what method names to give to the object method? clearly the name "process"  is something special for Maple here for some reason.

When I do ?process, I see that Maple has some commands that have this name. But this is a name of a method inside Object class, so it should not have anything to do with any Maple own command. 

This was never an issue with module() for an example.  If one has to worry about what name to give to their methods for an object, then this will be very awkward. For example, what if one calls their method FOO and future version of Maple introduce a new command called FOO now the code will no longer work.

 

 

Please Wait...