Conversation
886c0d9 to
01e8e40
Compare
thewilsonator
left a comment
There was a problem hiding this comment.
Looks good, needs a spec update though
| The generated invariant of an aggregate is now accessible as `__invariant` | ||
|
|
||
| The compiler generates one function per struct or class that calls all of its | ||
| `invariant` blocks. Previously it was not added to the symbol table, so it could | ||
| not be referred to. It is now a member named `__invariant`, like the generated | ||
| destructor is `__xdtor`, and is included in `__traits(allMembers)`. |
There was a problem hiding this comment.
While it's good to mention this in the changelog, I wouldn't advertise it as something users should reach for (double underscore means internal reserved name). Maybe mention the specialized use case.
There was a problem hiding this comment.
I'm actually tempted to just skip the changelog and spec entry for this... nobody wants to know about it, and in the future, allMembers will make it plainly discoverable to anyone.
There was a problem hiding this comment.
I did delete it; a double-underscore symbol isn't public contract, and I don't think we need to advertise it.
There was a problem hiding this comment.
While technically true, from experience with similar changes (like updating __unittest .mangleof) I have a strong feeling this will break someone's delicate introspection contraption when upgrading dmd, so it is courteous to mention it in that regard.
There was a problem hiding this comment.
I'm sure it will, but that's the reason we make no guarantees.
So, a changelog mention? I wouldn't spec it...?
DMD perf check
All measurements
f50dc28 vs merge-base 10adc6c · about these metrics |
fedb2f9 to
f5f23a5
Compare
I removed the changelog and spec update; I decided this is a private/internal symbol name, and shouldn't be part of the compiler contract. If you disagree, I can put it back, but I think this is correct; we should (theoretically) reserve the right to change People that ever care about this in the future will easily discover it among allMembers, but we should make no commitments. |
buildInv pushed the merged `__invariant` into the members but never added it to the symbol table, so `T.__invariant` could not be named. Add it, and list it in __traits(allMembers) like `__xdtor`.
f5f23a5 to
f50dc28
Compare
I see that ef S opAssign(ref S s)
{
S tmp = this; // bitcopy this into tmp
this = s; // bitcopy s into this
tmp.__dtor(); // call destructor on tmp
return this;
}and in the output of |
|
I think these should not appear in the spec personally. Are you expressing an opinion, or a ruling? Happy either way. |
buildInv pushes the merged
__invariantfunction into the members but never added it to the symbol table, soT.__invariantcould not be named (user invariants get numbered names). It is now added, and listed by __traits(allMembers) like__xdtor, so a runtime can take its address.This progresses towards runtime ClassInfo synthesis.