digitalmars.D.learn - cannot have overloaded nested functions?
- Timothee Cour (5/5) May 15 2013 why isn't this supported?
- Steven Schveighoffer (8/13) May 15 2013 Don't know, but it hasn't been supported ever. Spec clearly states it's...
- Jonathan M Davis (8/26) May 15 2013 You can't have multiple instantiations of templated nested functions eit...
- Timothee Cour (5/34) May 16 2013 at the very least (or until it gets fixed) dmd should emit a more friend...
- Jonathan M Davis (8/12) May 16 2013 I don't know what else it would say. It means exactly what it says. It's...
- Timothee Cour (9/27) May 16 2013 it could be friendlier.
- Jonathan M Davis (3/19) May 16 2013 Sounds fine to me. Open an enhancement request for it.
why isn't this supported? void main(){ void fun(); void fun(int x);//Error: declaration fun is already defined }
May 15 2013
On Wed, 15 May 2013 19:10:49 -0400, Timothee Cour <thelastmammoth gmail.com> wrote:why isn't this supported? void main(){ void fun(); void fun(int x);//Error: declaration fun is already defined }Don't know, but it hasn't been supported ever. Spec clearly states it's not supported, but not why. I suppose it is not difficult to name it something else? Note that there are a lot of different rules with nested functions that don't apply to normal functions. -Steve
May 15 2013
On Wednesday, May 15, 2013 20:48:19 Steven Schveighoffer wrote:On Wed, 15 May 2013 19:10:49 -0400, Timothee Cour <thelastmammoth gmail.com> wrote:You can't have multiple instantiations of templated nested functions either. IIRC, I created a bug report on it, and Walter closed it as won't fix, but I don't remember what his reasoning was, though IIRC, he was essentially of the opinion that nested functions didn't need to have the full capabilities of normal functions. I assume that that simplifies their implementation, but I don't know. - Jonathan M Daviswhy isn't this supported? void main(){ void fun(); void fun(int x);//Error: declaration fun is already defined }Don't know, but it hasn't been supported ever. Spec clearly states it's not supported, but not why. I suppose it is not difficult to name it something else? Note that there are a lot of different rules with nested functions that don't apply to normal functions.
May 15 2013
at the very least (or until it gets fixed) dmd should emit a more friendly error message: 'cannot overload a function in a nested scope' otherwise this is hard to understand. On Wed, May 15, 2013 at 11:43 PM, Jonathan M Davis <jmdavisProg gmx.com>wrote:On Wednesday, May 15, 2013 20:48:19 Steven Schveighoffer wrote:On Wed, 15 May 2013 19:10:49 -0400, Timothee Cour <thelastmammoth gmail.com> wrote:You can't have multiple instantiations of templated nested functions either. IIRC, I created a bug report on it, and Walter closed it as won't fix, but I don't remember what his reasoning was, though IIRC, he was essentially of the opinion that nested functions didn't need to have the full capabilities of normal functions. I assume that that simplifies their implementation, but I don't know. - Jonathan M Daviswhy isn't this supported? void main(){ void fun(); void fun(int x);//Error: declaration fun is already defined }Don't know, but it hasn't been supported ever. Spec clearly states it's not supported, but not why. I suppose it is not difficult to name it something else? Note that there are a lot of different rules with nested functions that don't apply to normal functions.
May 16 2013
On Thursday, May 16, 2013 00:28:15 Timothee Cour wrote:at the very least (or until it gets fixed) dmd should emit a more friendly error message: 'cannot overload a function in a nested scope' otherwise this is hard to understand.I don't know what else it would say. It means exactly what it says. It's telling you exactly what it can't do. Sure, it isn't telling you _why_ it's illegal, but error messages don't usually say that sort of thing anyway. So, if you have a good suggestion as to improve the error message, please create an enhancement request for it, but as far as I can tell, it means exactly what it says, and I don't know how it could be friendlier. - Jonathan M Davis
May 16 2013
as far as I can tell, it means exactly what it says, and I don't know howit could be friendlier. the error message 'declaration fun is already defined' is surprising because 'void fun(int x);' and 'void fun();' are typically 2 different function declarations, having different signatures. So this this sounds misleading/surprising.if you have a good suggestion as to improve the error message, pleasecreate an enhancement request for it how about: 'cannot overload a function in a nested scope' On Thu, May 16, 2013 at 12:35 AM, Jonathan M Davis <jmdavisProg gmx.com>wrote:On Thursday, May 16, 2013 00:28:15 Timothee Cour wrote:at the very least (or until it gets fixed) dmd should emit a morefriendlyerror message: 'cannot overload a function in a nested scope' otherwise this is hard to understand.I don't know what else it would say. It means exactly what it says. It's telling you exactly what it can't do. Sure, it isn't telling you _why_ it's illegal, but error messages don't usually say that sort of thing anyway. So, if you have a good suggestion as to improve the error message, please create an enhancement request for it, but as far as I can tell, it means exactly what it says, and I don't know how it could be friendlier. - Jonathan M Davis
May 16 2013
On Thursday, May 16, 2013 01:15:06 Timothee Cour wrote:Sounds fine to me. Open an enhancement request for it. - Jonathan M Davisas far as I can tell, it means exactly what it says, and I don't know howit could be friendlier. the error message 'declaration fun is already defined' is surprising because 'void fun(int x);' and 'void fun();' are typically 2 different function declarations, having different signatures. So this this sounds misleading/surprising.if you have a good suggestion as to improve the error message, pleasecreate an enhancement request for it how about: 'cannot overload a function in a nested scope'
May 16 2013