|
From: Joel A. <j.a...@gm...> - 2016-07-07 05:10:39
|
Hi, I'm working on the MATLAB module now (will return with a status report soon), but in the meantime I've got a style question. In the current version of the module, MATLAB's so-called "No Input Argument Constructor Requirement" is violated. This is a requirement that it should be able to call a class constructor without an argument and essentially just set default arguments: a = Foo(); If we implement the "No Input Argument Constructor Requirement", the code gets much cleaner and more efficient (no need to create a bunch of temporary objects). The problem is that this syntax is now being used to wrap the default C++ constructor. Does it make sense to let the default constructor be called with a static method instead (note that "default" is a keyword in C++, but not in MATLAB, so a very suitable name): a = Foo.default(); An alternative is to have the call to the default constructor be "lazy", i.e. called the first time a member function is called: a = Foo(); % <== Foo's C++ constructor not yet called disp(a); % <== Foo's C++ constructor will be called here Any thoughts on this? A mostly working of the above (with and without lazy constructor calls) can be found at: https://github.com/jaeandersson/swig/issues/31 Joel |