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
destructor of record in record is not called #334
Comments
Your custom destructor for |
So current behavior is correct? Or you are suggesting a workaround? |
Current behaviour is correct as far as i can tell. No need to call destroy() by default if it isn't required. |
Even if all record fields are POD, destroy still can be required (example: RawFile, SharedPointer). Weirdest thing is that destroy for "Inner" is called if "Inner" is stored in variable:
prints
These kinds of errors are very hard to spot. If this is really expected behavior (that is counter-intuitive), then compiler should at least issue a warning. |
Nothing wrong with your example, you've explicitly defined the destroy overload, so it takes precedence over the regular record destroy overload (which is only called for non-POD records). In Clay both RawFile and SharedPointer are defined as non-regular records and have destroy overloads defined in their respective modules. |
You are explaining why it works how it works. I got it now, thanks. I'm saying that the way it works is overcomplicated, so developers (like me) can easily make the error while implementing own types similar to Note, neither |
I guess over-complication is an issue for the language designers. At this stage i'm using Clay to learn about compiler design, i've really no idea if there is going to be any more serious development of the language , I hope so, but . . . who knows. Unfortunately the docs are incomplete and out-of-date. However, there are a lot of changes happening at this early stage so it may be a while before the docs catch-up. I've found there's usually enough examples in the lib to figure out how most things work though. |
BTW, problem seems to be solvable like this:
Will this work? |
You need to |
I like the idea of prohibiting overloads. How would it work? I think about final keywordFunction overloads can be annotated with
So:
how final helps with destroy
This won't fire compile-time error by default, because nobody's calling
other possible applications
|
I think it would be better if |
Closing this ticket, since final overload work is underway by @agemogolk |
prints
Record
Inner
has custom destructor and it is not called.The text was updated successfully, but these errors were encountered: