Thread overview
[Issue 8661] New: typeof not an attribute, doesn't work with UFCS
Sep 14, 2012
Jonathan M Davis
Sep 14, 2012
ixid
September 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8661

           Summary: typeof not an attribute, doesn't work with UFCS
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: monarchdodra@gmail.com


--- Comment #0 from monarchdodra@gmail.com 2012-09-14 05:57:31 PDT ---
In the title: Because "typeof" is a keyword,it does not have the same semantics as the other properties (http://dlang.org/property.html), such as stringof, sizeof etc..

For example:
--------
void main()
{
    int a;
    writeln(int.stringof);
    writeln(a.typeof.stringof); //This
    writeln(typeof(a).stringof);
}
--------
The syntax "a.typeof.stringof" should be made to work.

UFCS should not have a different behavior because typeof is a keyword.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8661


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-09-14 08:32:51 PDT ---
typeof isn't a function, nor is it a property. It's a built-in construct like is-expressions are. Would you want is-expressions to work with UFCS as well?

No, I think that this is trying to take UFCS too far.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8661


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #2 from bearophile_hugs@eml.cc 2012-09-14 09:54:18 PDT ---
(In reply to comment #1)
> typeof isn't a function, nor is it a property. It's a built-in construct like is-expressions are. Would you want is-expressions to work with UFCS as well?
> 
> No, I think that this is trying to take UFCS too far.

See my Issue 4272

I think "a.typeof" is a nice syntax to have, similar to "a.sizeof". But this isn't an example of UFCS.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8661


monarchdodra@gmail.com changed:

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


--- Comment #3 from monarchdodra@gmail.com 2012-09-14 11:17:23 PDT ---
Yeah... I should have opened it as ER, not Bug.

You are right, "nice to have". I searched if it existed before, but did not find your issue. Closing as duplicate.

*** This issue has been marked as a duplicate of issue 4272 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2012
Why is this taking it too far? In the duplicate you also expressed reservations about it without explaining why it's a bad idea. UFCS seems very much like the natural evolution of D's syntax and once (if) that's accepted it should be as consistent and general as possible.