You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Min external constructors have different behaviors and called twice. I would never want my constructor called twice and I want consistent behavior across scenarios.
A constructor to only be called once. Since the constructor is in the scope of the "top" max class, then this constructor would have no arguments. Please note, that checking the size() of arguments can not self-distinguish if it is the max class or the instance of that class, because arguments are not required and therefore it is valid to have zero arguments which would make both times the constructor is called appears extremely similar unless some state outside the constructor is used. But that's weird because now we are implementing a language feature (constructor only called once) with a state variable.
Repo 2
Change line 9 class foobar... to be instead the following class foobar : public object<foobar>, public matrix_operator<> {
In addition to the problem of the constructor running twice, now the second time it runs it no longer receives the "myarg" argument. This is drastically different behavior. The full list of non attribute arguments (non @... arguments) should be available to the constructor.
Notes
The number of times a constructor is called, in what context that constructor is called, and the arguments available to that constructor are all involved in this issue. Without guidance and examples from Cycling74, it is unclear the goal and context of constructors are in Min. Until that is clearer, I don't have any suggestions or fixes.
The text was updated successfully, but these errors were encountered:
There's a thread here (in the min-devkit issues) where they talk about this a bit. But I totally agree that this is odd behaviour, and I wish the constructor would be called just once.
@sncheca , thanks for looping in that issue. I'm on another project now, will revisit this in June 2020 and I can test if that's the double I see and also explore that dummy. It seems odd to create a dummy at runtime when all is known at compiletime. We have constexpr and cmake. 🤔
At the time this code was written, support for constexpr was very uneven (or non-existent) in the compilers across the support platforms.
That situation has likely improved and I agree that revisiting the need for a dummy instance to derive the class template is worth researching if and when time permits.
Min external constructors have different behaviors and called twice. I would never want my constructor called twice and I want consistent behavior across scenarios.
Setup
Code
Repo 1
Result 1
Max console reports the following
Expected 1
A constructor to only be called once. Since the constructor is in the scope of the "top" max class, then this constructor would have no arguments. Please note, that checking the size() of arguments can not self-distinguish if it is the max class or the instance of that class, because arguments are not required and therefore it is valid to have zero arguments which would make both times the constructor is called appears extremely similar unless some state outside the constructor is used. But that's weird because now we are implementing a language feature (constructor only called once) with a state variable.
Repo 2
class foobar...
to be instead the followingclass foobar : public object<foobar>, public matrix_operator<> {
calc_cell
method to the classResult 2
constructor... 0 arguments are:
jitclass_setup()
maxclass_setup()
foobar: constructor... 0 arguments are:
foobar: setup()
Expected 2
In addition to the problem of the constructor running twice, now the second time it runs it no longer receives the "myarg" argument. This is drastically different behavior. The full list of non attribute arguments (non
@...
arguments) should be available to the constructor.Notes
The number of times a constructor is called, in what context that constructor is called, and the arguments available to that constructor are all involved in this issue. Without guidance and examples from Cycling74, it is unclear the goal and context of constructors are in Min. Until that is clearer, I don't have any suggestions or fixes.
The text was updated successfully, but these errors were encountered: