www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11012] New: [TDPL] is(typeof(f) == function) fails with some functions

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

           Summary: [TDPL] is(typeof(f) == function) fails with some
                    functions
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei erdani.com



PDT ---
Consider TDPL example om page 150:

auto f = (int i) {};
assert(is(f == function));

That example has a typo, should be:

auto f = (int i) {};
assert(is(typeof(f) == function));

That still doesn't work, which brings us to this bug. The type of the function
is deduced as

void function(int i) pure nothrow  safe

and that fails the "is" test when compared against the bare "function" keyword.
As "function" by itself does not represent a type, the test should pass for all
functions, however qualified.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 11 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11012


Maxim Fomin <maxim maxim-fomin.ru> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |maxim maxim-fomin.ru



---
f is not a function but a function pointer, so the issue is against current
design and description of the issue is also misleading by the way.

By the way, this is a good opportunity to raise the question about what 'is'
expression should return. There are currently two kinds 'function' and
'delegate' for three cases - a function, function pointer and delegate.
Currently 'function' maps to function, not to a pointer and 'delegate' maps to
delegate which is inconsistent (there is also inconsistency with not mapping
'function' to function pointer as this keyword is related to function pointers
in other use cases). 

If 'function' should map to both pointer and a function, then there should be
some means to distingiush between them. Another option is to map 'function' to
pointer and function should map to returned type .

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