www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2716] New: Confusion of auto and scope as the class attribute

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716

           Summary: Confusion of auto and scope as the class attribute
           Product: D
           Version: unspecified
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: rayerd.wiz gmail.com


auto class B {}
void main()
{
        B x;
}
a.d(4): variable a.main.x reference to scope class must be scope


-- 
Mar 07 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID





An auto class and a scope class are the same thing.  What do you think auto
means in this context?


-- 
Mar 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


braddr puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |
            Version|unspecified                 |2.000





That use of auto is supposed to be going away.  I've reopened and assigned to
2.x.


-- 
Mar 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






What is this different something that auto in this context means now?  I can't
find it by a quick look through the docs.


-- 
Mar 08 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






The old concept of 'auto' meaning 'scope' should be dead.  It's death started
before the 1.0 release (if I remember my history correctly, don't feel like
searching the changelogs).  It appears that it isn't in this case.  'auto
class' should be either an error or a no-op depending on your philosophy of
redundant type prefixes.


-- 
Mar 08 2009
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|rejects-valid               |diagnostic





No redundant type prefix here.  auto either
(a) still means the same as scope, IWC this whole bug report is nonsense
(b) makes no sense here at all, IWC the rejects-valid keyword here is nonsense
- it's diagnostic here, possibly accepts-invalid

But there's something wrong - auto is still given on attribute.html, but the
way it's used there it doesn't seem to be an attribute.

Brad, while I have your ear, are you planning to catch up on the issues filed
here against puremagic.com itself any time soon?


-- 
Mar 08 2009
parent Sean Kelly <sean invisibleduck.org> writes:
d-bugmail puremagic.com wrote:
 
 But there's something wrong - auto is still given on attribute.html, but the
 way it's used there it doesn't seem to be an attribute.
'auto' was originally and continues to be a storage class. It's the default storage class if another one isn't specified, so the following are equivalent: auto int x = 5; int x = 5; Type inference happens via the omission of a type specifier, so auto is mostly used in this context, ie: auto x = 5; // int variable with a storage class of 'auto' const x = 5; // int variable with a storage class of 'const'
Mar 10 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






2009-07-12 08:23:17 PDT ---
Created an attachment (id=421)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=421)
Do not consider auto to mean scope.

This is a patch against LDC's DMDFE. It removes the remaining instances of auto
meaning scope and makes 'auto class C { ... }' and 'auto C c;' an 'Error:
storage class has no effect: auto'. See also bug 3118 .

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 12 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716







 Created an attachment (id=421)
--> (http://d.puremagic.com/issues/attachment.cgi?id=421) [details]
 Do not consider auto to mean scope.
 
 This is a patch against LDC's DMDFE. It removes the remaining instances of auto
 meaning scope and makes 'auto class C { ... }' and 'auto C c;' an 'Error:
 storage class has no effect: auto'. See also bug 3118 .
"storage class has no effect" seems to be the wrong wording. Firstly, it'll be a case of doesn't make sense rather than has no effect; secondly, this is making it not a storage class at all. Moreover, should we get rid of it straight off, or deprecate it first? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 13 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


Christian Kamm <kamm-removethis incasoftware.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kamm-removethis incasoftwar
                   |                            |e.de





2009-07-13 09:41:53 PDT ---
 "storage class has no effect" seems to be the wrong wording.
I'll change it if you come up with a nicer error message. "cannot be auto" would've been consistent with other error messages of this kind, but I thought the "has no effect" one was nicer.
 Firstly, it'll be a case of doesn't make sense rather than has no effect;
 secondly, this is making it not a storage class at all.
That's arguable. My reasoning was that as a do-nothing storage class, auto makes sense everywhere. Its only 'effect' is to allow type inference in the absence of another storage class.
 Moreover, should we get rid of it straight off, or deprecate it first?
I would've if it had ever been in the D1 spec, but as far as I remember it's around purely as a holdover from pre-D1. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 13 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716







 "storage class has no effect" seems to be the wrong wording.
I'll change it if you come up with a nicer error message. "cannot be auto" would've been consistent with other error messages of this kind, but I thought the "has no effect" one was nicer.
But "has no effect" reads to me to the effect that the compiler is supposed to just ignore it, rendering the fact that the error is generated confusing to the user. How about "both auto and explicit type given"?
 Firstly, it'll be a case of doesn't make sense rather than has no effect;
 secondly, this is making it not a storage class at all.
That's arguable. My reasoning was that as a do-nothing storage class, auto makes sense everywhere. Its only 'effect' is to allow type inference in the absence of another storage class.
The treatment of auto in this context as a storage class seems to be a hack to simplify parsing of declarations, which is useful only because of auto's ambiguity. If we get rid of auto's ambiguity as is being suggested, we should get rid of this hack while we're at it. More logical is to handle auto as a placeholder for a type in auto-typed declarations, as a direct part of the AutoDeclaration syntax (as I must've OUAT thought it already was). Something like (using * and + with their regexp meanings) AutoDeclaration: Attribute* auto Identifier = AssignExpression ; Attribute+ Identifier = AssignExpression ; Attribute* auto Attribute+ Identifier = AssignExpression ; (this last form is for backward compatibility, but could be removed or deprecated one day) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






---

 How about "both auto and explicit type given"?
Or even "both auto and explicit type given, use scope for RAII" for the benefit of returning D programmers and those otherwise trying to update legacy code. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






2009-07-14 09:35:40 PDT ---
I've switched the error message to "both auto and explicit type given". auto
class C {} will still trigger the "storage class has no effect" one though. I
don't think error messages of this kind are avoidable if you want to make
directly applying inapplicable storage classes an error.

By the way, bug 3118 would benefit from having a list of attributes and
declarations that should trigger an error if combined via direct application. I
can't guarantee I'll find the time to work on it though.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jul 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






---

 I've switched the error message to "both auto and explicit type given". auto
 class C {} will still trigger the "storage class has no effect" one though. I
 don't think error messages of this kind are avoidable if you want to make
 directly applying inapplicable storage classes an error.
Probably 99% of poorly written error messages can be improved if only one stops to think about it. How about "auto cannot be applied to classes" or "auto can only be applied to variable declarations"? We could use the same format for all illegal uses of attributes. Of course, the relevance of this to auto'll change when/if the grammar change proposed in comment 9 is implemented.... -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 14 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


Haruki Shigemori <rayerd.wiz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|x86                         |All
         OS/Version|Windows                     |All



20:53:16 PST ---

 An auto class and a scope class are the same thing.  What do you think auto
 means in this context?
I think "auto class" must be an error, because a scoped class is "scope class" already. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 01 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716






 An auto class and a scope class are the same thing.  What do you think auto
 means in this context?
I think "auto class" must be an error, because a scoped class is "scope class" already.
This as a meaning of auto may have been removed from the spec, but AIUI it was never the intention to withdraw it the moment scope was introduced. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 02 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------

           obsolete|                            |



PDT ---
Created an attachment (id=636)
Update previous patch to tip of svn

I've updated this diff to the the current tip of svn 493.

I altered the error messages to point suggest that the user probably wants to
use the scope storage class when it finds the deprecated use of auto.

I've also run this through the dmd test suite (which needs some corresponding
changes that I'll send to Walter privately).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 18 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



00:16:49 PDT ---
http://www.dsource.org/projects/dmd/changeset/639

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


Haruki Shigemori <rayerd.wiz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |



01:09:13 PDT ---
Thank you for your great job!
However, this invalid code is accepted yet.

auto class A{} // <-- not "scope"
void main()
{
    scope a = new A();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2716


Haruki Shigemori <rayerd.wiz gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED



01:52:44 PDT ---
Oh! Sorry...
This issue is already fixed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 28 2010