www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Type inference bug: properties

reply "John C" <johnch_atms hotmail.com> writes:
Type inference doesn't work on class properties.

    class TestClass {
        int value() { return 5; }
    }

    TestClass c = new TestClass;
    auto v = c.value; // changing this to 'auto v = c.value()' does work
Oct 26 2005
next sibling parent Carlos Santander <csantander619 gmail.com> writes:
John C escribió:
 Type inference doesn't work on class properties.
 
     class TestClass {
         int value() { return 5; }
     }
 
     TestClass c = new TestClass;
     auto v = c.value; // changing this to 'auto v = c.value()' does work
 
 
 
Another case in favor (I think) to have a special syntax for properties, instead of what we currently have. -- Carlos Santander Bernal
Oct 26 2005
prev sibling parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John C schrieb am 2005-10-26:
 Type inference doesn't work on class properties.

     class TestClass {
         int value() { return 5; }
     }

     TestClass c = new TestClass;
     auto v = c.value; // changing this to 'auto v = c.value()' does work
Should v be an int or a delegate? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDYfrX3w+/yD4P9tIRAl/tAKDBag2AXtGq1mDTOfDBWC5V7D+7bQCfYBsr NPbBdSqyVN2vaDB8FRy99eA= =lnHF -----END PGP SIGNATURE-----
Oct 28 2005
parent "John C" <johnch_atms hotmail.com> writes:
"Thomas Kuehne" <thomas-dloop kuehne.cn> wrote in message 
news:nfa933-vh6.ln1 eiche.kuehne.cn...
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1

 John C schrieb am 2005-10-26:
 Type inference doesn't work on class properties.

     class TestClass {
         int value() { return 5; }
     }

     TestClass c = new TestClass;
     auto v = c.value; // changing this to 'auto v = c.value()' does work
Should v be an int or a delegate?
An int. The correct syntax for a delegate would be: auto v = &c.value as this test shows: auto v1 = c.value(); auto v2 = &c.value; writefln("type = " ~ typeid(typeof(v1)).toString()); // type = int writefln("type = " ~ typeid(typeof(v2)).toString()); // type = int delegate()
 Thomas

 -----BEGIN PGP SIGNATURE-----

 iD8DBQFDYfrX3w+/yD4P9tIRAl/tAKDBag2AXtGq1mDTOfDBWC5V7D+7bQCfYBsr
 NPbBdSqyVN2vaDB8FRy99eA=
 =lnHF
 -----END PGP SIGNATURE----- 
Oct 29 2005