Stack overflow error
    Bill Baxter 
    dnewsgroup at billbaxter.com
       
    Sun Jan 21 16:45:20 PST 2007
    
    
  
Andrey Khropov wrote:
> Bill Baxter wrote:
> 
> 
>> Oh, you do realize D treats  'blah' as a synonym for 'blah()' if blah is a
>> function or delegate, right?
> 
> I think it's a harmful and error-prone feature. And it's also inconsistent:
> 
> auto f2 = f; // here f is treated like a variable
> f; // here f means call itself, but it looks exactly the same
> 
> Why on earth is this needed ?
> 
I know what you mean.  But it's very handy in the context of methods 
that masquerade as properties.  So you can say obj.prop instead of 
obj.prop().  I think I would prefer, though, if that feature had to be 
explicitly enabled for a particular method.  Something like:
     property float prop() { return m_prop; }
Then for most functions (which aren't properties) we could dispense with 
the & required to take the address.
On the other hand there is something to be said for consistency and 
regularity.  foo is synonymous with foo() if foo is a function.  Period. 
   So I can sorta see why Walter made it the way it is.  That and 
probably it was a lot easier to implement the way it is, since the 
compiler doesn't have to keep track of whether a function is a 
'property' function or not.
--bb
    
    
More information about the Digitalmars-d-bugs
mailing list