3787 – clarification: assigment to 'this'

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3787 - clarification: assigment to 'this'
Summary: clarification: assigment to 'this'
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords: spec
Depends on:
Blocks:
Reported: 2010年02月09日 08:02 UTC by Johannes Pfau
Modified: 2015年06月09日 05:14 UTC (History)
3 users (show)

See Also:


Attachments
Example of assignment to this (825 bytes, application/octet-stream)
2010年02月09日 08:02 UTC, Johannes Pfau
Details
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Johannes Pfau 2010年02月09日 08:02:26 UTC
Created attachment 564 [details] 
Example of assignment to this
Assigning to 'this' is currently not documented anywhere. Still assigning to
this, at least in constructors, works and is used by some code (gtkd, for
example). I think assigning to this should either work in constructors as it
does right now, but it then should be documented, or it should be disallowed.
If it will stay implementation specific, that should still be noted in the
docs.
see also: http://d.puremagic.com/issues/show_bug.cgi?id=780 The assignment of
'this' is allowed
Comment 1 Andrei Alexandrescu 2010年02月09日 08:42:34 UTC
This doesn't look major.
Comment 2 Johannes Pfau 2010年02月09日 10:54:37 UTC
I just thought if you'd disallow assignment to this completely as the poster in bug 780 suggests, you might want to discuss that in the newsgroup. As this is quite late for d2 I flagged it major. Also I think completely undocumented and undefined features being already used in production code (gtkd) is a bad thing.
However, I hadn't seen the bugzilla fields explanation, sorry. I'll change the priority.
Btw, what is most likely to happen in the end?
1: make current behavior part of specification
2: disallow assignment to this completely
3: leave this as implementation specific behavior
Comment 3 Walter Bright 2012年01月22日 13:34:48 UTC
Assignment to this and super should not be allowed.
The gtkd code can be fixed by making a 'factory' method to create a new object. However, this is not a trivial fix, and so having the compiler disallow the current code should be a long time in coming.
In the meantime, I've updated the spec.


AltStyle によって変換されたページ (->オリジナル) /