-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
constructors called twice and have different behaviors/argument values #144
Comments
Hey diablodale, 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 |
At the time this code was written, support for 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. Cheers |
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: