Thread overview
[Issue 4987] New: C function pointer syntax needs to be deprecated
Oct 04, 2010
Don
Oct 05, 2010
Walter Bright
Nov 04, 2010
Jerry Quinn
Dec 31, 2011
Don
October 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4987

           Summary: C function pointer syntax needs to be deprecated
           Product: D
           Version: D1 & D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: clugdbug@yahoo.com.au


--- Comment #0 from Don <clugdbug@yahoo.com.au> 2010-10-04 01:14:13 PDT ---
This patch also gives a reasonable fix for bug 4962, "Improve error message for
wrong constructor name?"
It also gives nice error messages for missing return types in function
declarations.
Most importantly, it makes x(y) an invalid type, instead of being a declaration
of a 'y', where &y is type 'x function()'. It's critical that syntax be
removed.

---

PATCH: parse.c, Parser::parseDeclarator() line 2497
----
        case TOKlparen:
            if (peekNext() == TOKmul || peekNext() == TOKlparen ||
                peekNext() == TOKlbracket)
            {
                /* Parse things with parentheses around the identifier, like:
                 *  int (*ident[3])[]
                 * although the D style would be:
                 *  int[]*[3] ident
                 */
                if (!global.params.useDeprecated) {
                    error("C-style function pointer syntax is deprecated. Use
'function' to declare function pointers");
                }
                nextToken();
                ts = parseDeclarator(t, pident);
                check(TOKrparen);
                break;
            }
            ts = t;
            Token *peekt = &token;
            // Improve error messages for the common bug of a missing return
type
            if (isParameters(&peekt)) {
                error("function declaration without return type. "
                "(Note that constructors are always named 'this')");
            }
            else
                error("unexpected ( in declarator");
            break;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 05, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4987


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-10-05 00:19:23 PDT ---
I changed it for D2 only, in order to avoid breaking existing D1 code.

http://www.dsource.org/projects/dmd/changeset/703

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 04, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4987


Jerry Quinn <jlquinn@optonline.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jlquinn@optonline.net


--- Comment #2 from Jerry Quinn <jlquinn@optonline.net> 2010-11-04 13:59:10 PDT ---
(In reply to comment #1)
> I changed it for D2 only, in order to avoid breaking existing D1 code.
> 
> http://www.dsource.org/projects/dmd/changeset/703

The language grammar (declaration.html) also needs to be updated.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 31, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4987


Don <clugdbug@yahoo.com.au> changed:

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


--- Comment #3 from Don <clugdbug@yahoo.com.au> 2011-12-30 16:44:23 PST ---
(In reply to comment #2)
> (In reply to comment #1)
> > I changed it for D2 only, in order to avoid breaking existing D1 code.
> > 
> > http://www.dsource.org/projects/dmd/changeset/703
> 
> The language grammar (declaration.html) also needs to be updated.

It's marked as deprecated in declaration.html. As long as it's deprecated but not removed, I think it should remain as part of the grammer.

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