Question: what is difference between person_class:=module() and module person_class() ?

When making a module with option object, help says 

To create a new class of objects, use the named module declaration syntax with option object.

and it gives an example.  But what is the difference from using the standard module syntax?

This seems to work the same but may be there are cases where it makes a difference?  Here is an example. second case below is what help says to use. But first case is the original module syntax. Both work the same in this simple example.

Can one use either syntax, or is there any subtle difference in semantics that will show under more complicated setup?

interface(version);

`Standard Worksheet Interface, Maple 2023.0, Windows 10, March 6 2023 Build ID 1689885`

restart;

1421372

person_class:=module()
  option object;
  export foo::static:=proc(_self,$)
    print("in foo");
    NULL;
  end proc;
end module;

o:=Object(person_class);
o:-foo();

_m2325067887584

_m2325067872032

"in foo"

restart;

1421372

module person_class()
  option object;
  export foo::static:=proc(_self,$)
    print("in foo");
    NULL;
  end proc;
end module;
o:=Object(person_class);
o:-foo();

module person_class () option object; end module

module person_class () option object; end module

"in foo"

 


Download syntax_of_OOP_module.mw

Please Wait...