www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - D1->D2 member call syntax regression?

reply "Nick Sabalausky" <a a.a> writes:
In converting some D1 code to D2, I noticed this doesn't seem to work 
anymore:

module mymodule;
class Foo()
{
    void bar(string s) {...}

    void foo()
    {
        string str = "hello";
        str.bar();
    }
}

In D1 that works fine, but in D2 (2.047) it complains that it can't find 
"mymodule.bar". That's a bit dissapointing, as I keep hoping member call 
syntax will eventually get expanded, not reduced. Is this a bug, or is there 
some reason for it?
Jul 27 2010
next sibling parent Jonathan M Davis <jmdavisprog gmail.com> writes:
On Tuesday, July 27, 2010 16:25:28 Nick Sabalausky wrote:
 In converting some D1 code to D2, I noticed this doesn't seem to work
 anymore:
 
 module mymodule;
 class Foo()
 {
     void bar(string s) {...}
 
     void foo()
     {
         string str = "hello";
         str.bar();
     }
 }
 
 In D1 that works fine, but in D2 (2.047) it complains that it can't find
 "mymodule.bar". That's a bit dissapointing, as I keep hoping member call
 syntax will eventually get expanded, not reduced. Is this a bug, or is
 there some reason for it?

It looks more like a bug fix to me given that the first parameter to bar() is the invisible this rather than a string, but since I've never used D1, I certainly can't compare what it does to D2. - Jonathan M Davis
Jul 27 2010
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
It seems to work, on 2.042, and on dmd 2.047:
http://ideone.com/dcsK3

Bye,
bearophile
Jul 27 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:i2nqs5$jss$1 digitalmars.com...
 It seems to work, on 2.042, and on dmd 2.047:
 http://ideone.com/dcsK3

 Bye,
 bearophile

That's because my original example accidentally made Foo an uninstantiated class template, so the compiler never bothered to check the semantics... The following fails on 2.046 and 2.042, but works fine on 1.062: class Foo { void bar(string s) {} void foo() { string str = "hello"; str.bar(); } } void main() {}
Jul 27 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:i2o9ev$1e4h$1 digitalmars.com...
 "bearophile" <bearophileHUGS lycos.com> wrote in message 
 news:i2nqs5$jss$1 digitalmars.com...
 It seems to work, on 2.042, and on dmd 2.047:
 http://ideone.com/dcsK3

 Bye,
 bearophile

That's because my original example accidentally made Foo an uninstantiated class template, so the compiler never bothered to check the semantics... The following fails on 2.046 and 2.042, but works fine on 1.062: class Foo { void bar(string s) {} void foo() { string str = "hello"; str.bar(); } } void main() {}

The above also fails on 2.047
Jul 27 2010
prev sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Nick Sabalausky:
 That's because my original example accidentally made Foo an uninstantiated 
 class template, so the compiler never bothered to check the semantics...

Surely here there is no shortage of ways I can paint myself as a stupid :-) In Python the () after the class name are optional and they do nothing, so I didn't see them in that little D program :-) Bye, bearophile
Jul 28 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"bearophile" <bearophileHUGS lycos.com> wrote in message 
news:i2p4iq$po$1 digitalmars.com...
 Nick Sabalausky:
 That's because my original example accidentally made Foo an 
 uninstantiated
 class template, so the compiler never bothered to check the semantics...

Surely here there is no shortage of ways I can paint myself as a stupid :-) In Python the () after the class name are optional and they do nothing, so I didn't see them in that little D program :-)

*I'm* the one that was dumb enough put them there in the first place! And I can't use "extensive Python experience" as an excuse ;)
Jul 28 2010
parent reply "Nick Sabalausky" <a a.a> writes:
"Nick Sabalausky" <a a.a> wrote in message 
news:i2pvvi$2g83$1 digitalmars.com...
 "bearophile" <bearophileHUGS lycos.com> wrote in message 
 news:i2p4iq$po$1 digitalmars.com...
 Nick Sabalausky:
 That's because my original example accidentally made Foo an 
 uninstantiated
 class template, so the compiler never bothered to check the semantics...

Surely here there is no shortage of ways I can paint myself as a stupid :-) In Python the () after the class name are optional and they do nothing, so I didn't see them in that little D program :-)

*I'm* the one that was dumb enough put them there in the first place! And I can't use "extensive Python experience" as an excuse ;)

It still leaves the question though, "Why isn't that working in D2? Bug or legitimate reason?". Jonathan suggested it was deliberate because of the hidden "this" parameter, but I'm not convinced because 1) D1 has the hidden "this" param too, but it handles it just fine, and 2) It's just a syntactical issue, so I don't see how semantics could be a problem unless there's some other change in D2 that causes a conflict or ambiguity with that feature. In any case, the error message seems to indicate that, deliberate or not, it's likely some sort of symbol-lookup/visibility issue.
Jul 28 2010
parent reply Don <nospam nospam.com> writes:
Nick Sabalausky wrote:
 "Nick Sabalausky" <a a.a> wrote in message 
 news:i2pvvi$2g83$1 digitalmars.com...
 "bearophile" <bearophileHUGS lycos.com> wrote in message 
 news:i2p4iq$po$1 digitalmars.com...
 Nick Sabalausky:
 That's because my original example accidentally made Foo an 
 uninstantiated
 class template, so the compiler never bothered to check the semantics...

:-) In Python the () after the class name are optional and they do nothing, so I didn't see them in that little D program :-)

I can't use "extensive Python experience" as an excuse ;)

It still leaves the question though, "Why isn't that working in D2? Bug or legitimate reason?". Jonathan suggested it was deliberate because of the hidden "this" parameter, but I'm not convinced because 1) D1 has the hidden "this" param too, but it handles it just fine, and 2) It's just a syntactical issue, so I don't see how semantics could be a problem unless there's some other change in D2 that causes a conflict or ambiguity with that feature. In any case, the error message seems to indicate that, deliberate or not, it's likely some sort of symbol-lookup/visibility issue.

intermediate versions installed.
Jul 28 2010
parent "Nick Sabalausky" <a a.a> writes:
"Don" <nospam nospam.com> wrote in message 
news:i2q0un$2hud$1 digitalmars.com...
 Nick Sabalausky wrote:
 It still leaves the question though, "Why isn't that working in D2? Bug 
 or legitimate reason?".

 Jonathan suggested it was deliberate because of the hidden "this" 
 parameter, but I'm not convinced because 1) D1 has the hidden "this" 
 param too, but it handles it just fine, and 2) It's just a syntactical 
 issue, so I don't see how semantics could be a problem unless there's 
 some other change in D2 that causes a conflict or ambiguity with that 
 feature.

 In any case, the error message seems to indicate that, deliberate or not, 
 it's likely some sort of symbol-lookup/visibility issue.

intermediate versions installed.

I've gone ahead and filed a bug report: http://d.puremagic.com/issues/show_bug.cgi?id=4525
Jul 28 2010