Thread overview
[Issue 1354] New: Can use function prototype in typedef and alias.
Jul 20, 2007
d-bugmail
Jul 20, 2007
d-bugmail
Jul 31, 2007
d-bugmail
July 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1354

           Summary: Can use function prototype in typedef and alias.
           Product: D
           Version: 1.017
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: aziz.kerim@gmail.com


typedef int[] func(A,B,C)(int bla); // works with alias instead of typedef,
too.
func foo; // Error: variable foo cannot be declared to be a function
func* foo; // works


-- 

July 20, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1354


shro8822@vandals.uidaho.edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |shro8822@vandals.uidaho.edu




------- Comment #1 from shro8822@vandals.uidaho.edu  2007-07-20 15:45 -------
Why should having a typedef to a function type be an issue?

It might be but I'm not seeing it.


-- 

July 31, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1354





------- Comment #2 from aziz.kerim@gmail.com  2007-07-31 04:44 -------
(In reply to comment #1)
> Why should having a typedef to a function type be an issue?
> 
> It might be but I'm not seeing it.
> 

The problem is that the compiler ignores the template parameter list. The compiler should either flag this as an error or allow for such declarations.

A declaration like:

typedef A[] func(A, B)(B bla);

should be seen by the compiler as:

template func(A, B)
{
  typedef A[] func(B bla);
}

Instantiate template:

func!(int, int)* foo;


--