Skip to content

Conversation

@RazvanN7
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the annotated coverage diff directly on GitHub with CodeCov's browser extension
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@andralex
Copy link
Member

@RazvanN7 - need to define what happens when the entire struct is qualified and then defines a postblit with no qualifier/same qualifier/different qualifier.

@andralex
Copy link
Member

@RazvanN7 please add examples after each major paragraphs. RUNNABLE_EXAMPLE should be great here. @wilzbach we'd really need a ERROR_EXAMPLE here, do you think you could add that to our build infra?

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-containing + no information that will be out of date soon please

spec/struct.dd Outdated
$(D this(this) immutable;) or $(D this(this) shared;), then the code
is ill-formed. Historically, such definitions passed compilation but
could not be invoked. A deprecation diagnostic is issued by the front-end
of dmd 2.080 or later, see $(BUGZILLA 18417). Example:)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't add things that can get outdated into the spec, because they will.
Info this belongs into the changelog entry

spec/struct.dd Outdated

$(P If a postblit is qualified with `const` as in $(D this(this) const;),
the code is ill-formed. A deprecation diagnostic is issued by the
front-end of dmd 2.080 or later, see $(BUGZILLA 18417). Prior versions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again information that will get outdated, better not add it.

spec/struct.dd Outdated
}
---

$(P This allows incorrect code to compile, refer to $(BUGZILLA 18357) for examples.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work. The spec should be self-containing as Bugzilla might be offline or it simply might be print as ebook or PDF.

@wilzbach
Copy link
Contributor

Out of interest: does this try to address https://issues.dlang.org/show_bug.cgi?id=14246?
(see also the proposed changes + tests in dlang/dmd#6816)

@wilzbach
Copy link
Contributor

. @wilzbach we'd really need a ERROR_EXAMPLE here,

There's already SPEC_RUNNABLE_EXAMPLE_FAIL - doesn't that work for you?
I wanted to add support for the error messages too, but after thinking about it for a few weeks, I'm not so sure anymore. The problem is that every time when the error message gets updated, the spec would require an update too. Now the problem is how do you update the spec to the new compiler message without breaking DAutoTest? This would mean:

  • PR to dlang.org to disable the test
  • PR to dmd to fix the error message
  • PR to dlang.org to enable the test again and update the error message

Not sure whether we really want to increase our cross-repository even further.

@RazvanN7
Copy link
Contributor Author

Out of interest: does this try to address https://issues.dlang.org/show_bug.cgi?id=14246?

No, this PR documents solely the postblitting mechanism; it's a work in progress, though.

Copy link
Member

@andralex andralex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of minor changes requested

internal postblit functions:)

$(OL
$(LI `void __postblit()`. The compiler assigns this name to the explicitly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please specify entire signatures (as I did in the commit I added) and make sure those I added are correct.

---
)

$(P Neither of the above postblits is defined for structs that don't
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should specify somewhere (perhaps here) what happens if someone does NOT define this(this) but DOES define the special functions. Is the compiler going to insert the calls? (Hopefully not!)

spec/struct.dd Outdated
---
)

$(P Postblits are not overloadable. If two or more postblits are defined,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better (missed this): "Postblits cannot be overloaded." The word "overloadable" is a bit awkward.


$(OL
$(LI `const`. When a postblit is qualified with `const` as in
$(D this(this) const;) or $(D const this(this);) then the postblit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the "is ill-formed" part here because the code is accepted. Please don't forget - we're documenting behavior here, not what should happen. If we deprecate this with the next version, then yes please do mention it's ill-formed but no diagnostic is issues by front-end versions prior to 2.xxx.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will deprecate this with the next version, but @wilzbach argued that information that gets outdated should not be in the spec. I thought that saying it's ill-formed but not mentioning the deprecation is the best compromise since you can actually call the function but it's not doing what it is supposed to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's helpful to give that information so people who see invalid code getting compiled don't get confused.

$(OL
$(LI `const`. When a postblit is qualified with `const` as in
$(D this(this) const;) or $(D const this(this);) then the postblit
is succesfully called on mutable (unqualified), `const`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the backquotes around mutable because mutable is not a keyword.

$(LI `immutable`. When a postblit is qualified with `immutable`
as in $(D this(this) immutable) or $(D immutable this(this))
the code is ill-formed. The `immutable` postblit passes the
compilation phase but cannot be invoked. Example:)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version when this will be diagnosed? I think we can leave this text as is and add a mention once we merge the appropriate PR.

@JinShil JinShil added the Vision https://wiki.dlang.org/Vision/2018H1 label Mar 23, 2018
@andralex andralex merged commit 36f7800 into dlang:master Mar 23, 2018
@wilzbach
Copy link
Contributor

wilzbach commented Mar 30, 2018

Sorry for being late to the party, but should the behavior for an array of structs be defined too?
At the moment DMD calls __ArrayPostblit which is automatically added to object.d, but that might change soon: dlang/dmd#8067

In any case, the behavior for now is:

foreach (ref e; cast(S*)this.v.ptr)[0 .. n])
      e.__xpostblit();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Vision https://wiki.dlang.org/Vision/2018H1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants