Bug 8661 – typeof not an attribute, doesn't work with UFCS
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-14T05:57:00Z
Last change time
2015-06-09T05:14:56Z
Assigned to
nobody
Creator
monarchdodra
Comments
Comment #0 by monarchdodra — 2012-09-14T05:57:31Z
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.
Comment #1 by issues.dlang — 2012-09-14T08:32:51Z
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.
Comment #2 by bearophile_hugs — 2012-09-14T09:54:18Z
(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.
Comment #3 by monarchdodra — 2012-09-14T11:17:23Z
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 ***