digitalmars.D.bugs - Stack overflow error
- Marcio Faustino (6/6) Jan 20 2007 The following code:
- Johan Granberg (3/11) Jan 20 2007 This is a programmer error. you are calling the function f within the
- Bill Baxter (7/14) Jan 20 2007 Are you saying you'd like D to implement the tail recursion elimination
- Marcio Faustino (3/4) Jan 20 2007 function or delegate, right?
- Bill Baxter (5/10) Jan 20 2007 No need to apologize. I was surprised by that one too, initially, even
- Andrey Khropov (6/8) Jan 21 2007 I think it's a harmful and error-prone feature. And it's also inconsiste...
- Lionello Lunesu (9/18) Jan 21 2007 (implicit) properties.
- Bill Baxter (15/28) Jan 21 2007 I know what you mean. But it's very handy in the context of methods
The following code: void f() { f; } void main() { f(); } compiled by DMD v1.0 (on Windows XP) generates an "Error: Stack Overflow" error.
Jan 20 2007
Marcio Faustino wrote:The following code: void f() { f; } void main() { f(); } compiled by DMD v1.0 (on Windows XP) generates an "Error: Stack Overflow" error.This is a programmer error. you are calling the function f within the function f causing an infinite recursion.
Jan 20 2007
Marcio Faustino wrote:The following code: void f() { f; } void main() { f(); } compiled by DMD v1.0 (on Windows XP) generates an "Error: Stack Overflow" error.Are you saying you'd like D to implement the tail recursion elimination optimization? Because most C/C++ compilers would probably generate a stack overflow on the equivalent of that code too. Oh, you do realize D treats 'blah' as a synonym for 'blah()' if blah is a function or delegate, right? --bb
Jan 20 2007
Bill Baxter wrote:Oh, you do realize D treats 'blah' as a synonym for 'blah()' if blah > is afunction or delegate, right? Didn't know that, how dumb of me. Sorry.
Jan 20 2007
Marcio Faustino wrote:Bill Baxter wrote:No need to apologize. I was surprised by that one too, initially, even though I knew methods could be called without the (). I just didn't expect that would extend to top-level functions too. --bbOh, you do realize D treats 'blah' as a synonym for 'blah()' if blah > is afunction or delegate, right? Didn't know that, how dumb of me. Sorry.
Jan 20 2007
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 ? --
Jan 21 2007
"Andrey Khropov" <andkhropov_nosp m_mtu-net.ru> wrote in message news:ep01si$o08$1 digitaldaemon.com...Bill Baxter wrote:(implicit) properties. #auto f2 = f; // f can be a variable or a property getter (Uhm, that would work, if there weren't that issue with using auto + a getter that way.) I like this feature. It gets rid of many () pairs, and I think it's a straightforward way for properties. L.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 ?
Jan 21 2007
Andrey Khropov wrote:Bill Baxter wrote: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. --bbOh, 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 ?
Jan 21 2007