digitalmars.D - Function literals can't be class members
- JS (14/14) Jul 08 2013 trying to use a lambda inside a sub template gives an error.
- JS (2/16) Jul 09 2013 Anyone have any ideas?
- Dicebot (3/4) Jul 09 2013 Yes and I will answer once you start asking question in D.learn
- JS (2/6) Jul 09 2013 Thanks... I'll just keep posting in here then...
- John Colvin (8/15) Jul 09 2013 Please don't. Posting in d.learn to check you haven't missed
- Dicebot (9/12) Jul 09 2013 I am always ready to help when it makes sense. But there is a
- Joseph Rushton Wakeling (5/6) Jul 09 2013 You know, most people, when they get informed there's a dedicated
- Maxim Fomin (9/16) Jul 09 2013 You should know that when you post such things your are insulting
- John Colvin (26/40) Jul 09 2013 This belongs in D.learn.
- JS (22/65) Jul 09 2013 Maybe you need to go tell Artur that he is wrong first before you
- John Colvin (7/80) Jul 09 2013 I am genuinely confused. Nothing in Arturs code or your example
trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda produces no error, yet all are essentially semantically equivalent... just the lamda version requires less typing. (in fact, it would be nice to have a simplification of template b() = { ... }();)
Jul 08 2013
On Monday, 8 July 2013 at 22:41:41 UTC, JS wrote:trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda produces no error, yet all are essentially semantically equivalent... just the lamda version requires less typing. (in fact, it would be nice to have a simplification of template b() = { ... }();)Anyone have any ideas?
Jul 09 2013
On Tuesday, 9 July 2013 at 09:44:17 UTC, JS wrote:Anyone have any ideas?Yes and I will answer once you start asking question in D.learn newsgroup.
Jul 09 2013
On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote:On Tuesday, 9 July 2013 at 09:44:17 UTC, JS wrote:Thanks... I'll just keep posting in here then...Anyone have any ideas?Yes and I will answer once you start asking question in D.learn newsgroup.
Jul 09 2013
On Tuesday, 9 July 2013 at 10:45:40 UTC, JS wrote:On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote:Please don't. Posting in d.learn to check you haven't missed something stupid, then following it up with either a bug report or a post in the main newsgroup if appropriate is good practice. We all make mistakes from time-to-time. P.S. Dicebot's responses to your questions have been by-and-large correct and informative. I'm sure he genuinely means he will try to help you if you post in the correct place.On Tuesday, 9 July 2013 at 09:44:17 UTC, JS wrote:Thanks... I'll just keep posting in here then...Anyone have any ideas?Yes and I will answer once you start asking question in D.learn newsgroup.
Jul 09 2013
On Tuesday, 9 July 2013 at 11:06:22 UTC, John Colvin wrote:P.S. Dicebot's responses to your questions have been by-and-large correct and informative. I'm sure he genuinely means he will try to help you if you post in the correct place.I am always ready to help when it makes sense. But there is a major difference between helping a newbie which does not yet know where to ask for help and being patient in presence of arrogant aggression. I really think simply ignoring all JS questions until he learns to not flood main newsgroup is the right think to do and your attempt to be friendly does not help here. One-sided friendliness is just asking for an abuse. Exactly what JS does, intentionally.
Jul 09 2013
On 07/09/2013 12:45 PM, JS wrote:Thanks... I'll just keep posting in here then...You know, most people, when they get informed there's a dedicated newsgroup/mailing list for language questions, are polite enough to say thank you for the information, and take their question over to the appropriate place. Generally speaking they have a better time getting answers, too :-)
Jul 09 2013
On Tuesday, 9 July 2013 at 10:45:40 UTC, JS wrote:On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote:You should know that when you post such things your are insulting not only one particular person, but litter dozens of mailboxes with your abusive messages. There are many people hanging around here and many more who just read and interfere if matter. If you think that your provoking style is boosting your "acknowledgement" here then you are wrong, in fact you are boosting your chances to get banned for trolling, as was mentioned in previous discussions, let alone getting help.On Tuesday, 9 July 2013 at 09:44:17 UTC, JS wrote:Thanks... I'll just keep posting in here then...Anyone have any ideas?Yes and I will answer once you start asking question in D.learn newsgroup.
Jul 09 2013
On Monday, 8 July 2013 at 22:41:41 UTC, JS wrote:trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda produces no error, yet all are essentially semantically equivalent... just the lamda version requires less typing. (in fact, it would be nice to have a simplification of template b() = { ... }();)This belongs in D.learn. The code you provided is never going to give any "Function literals can't be class members" error, although it does have a lot of other things wrong with it. 1) The mixin template has no parameter list. 2) enum b = { }(); isn't valid without a function body. Did you mean (){} ? 3) and it definitely isn't going to return a string to work with mixin(); It helps to give code examples that are at least syntactically correct, if not immediately compilable. A correct and simplified test case of what I *think* you are talking about is this: mixin template A() { auto foo = (){ }; } class C { mixin A!(); } Error: delegate f977.C.A!().__lambda1 function literals cannot be class members Lambda function and delegate literals cannot be class members. Function literals can. I'm not entirely sure on the reason why, it's probably to do with context pointers.
Jul 09 2013
On Tuesday, 9 July 2013 at 10:25:26 UTC, John Colvin wrote:On Monday, 8 July 2013 at 22:41:41 UTC, JS wrote:Maybe you need to go tell Artur that he is wrong first before you bitch at me for being wrong... http://forum.dlang.org/thread/myalrxrrwoljxbboaymh forum.dlang.org Please, at least if you are going to bitch and talk down to me about writing valid source code at least know what you are talking about in the first place... module main; import std.stdio, std.cstream; template b() { enum b = { return "\"asdf\""; }(); pragma(msg, b); } int main(string[] argv) { auto f = (){ writeln("asd"); }; f(); writeln(mixin(b!())); din.getc(); return 0; }trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda produces no error, yet all are essentially semantically equivalent... just the lamda version requires less typing. (in fact, it would be nice to have a simplification of template b() = { ... }();)This belongs in D.learn. The code you provided is never going to give any "Function literals can't be class members" error, although it does have a lot of other things wrong with it. 1) The mixin template has no parameter list. 2) enum b = { }(); isn't valid without a function body. Did you mean (){} ? 3) and it definitely isn't going to return a string to work with mixin(); It helps to give code examples that are at least syntactically correct, if not immediately compilable. A correct and simplified test case of what I *think* you are talking about is this: mixin template A() { auto foo = (){ }; } class C { mixin A!(); } Error: delegate f977.C.A!().__lambda1 function literals cannot be class members Lambda function and delegate literals cannot be class members. Function literals can. I'm not entirely sure on the reason why, it's probably to do with context pointers.
Jul 09 2013
On Tuesday, 9 July 2013 at 11:03:34 UTC, JS wrote:On Tuesday, 9 July 2013 at 10:25:26 UTC, John Colvin wrote:I am genuinely confused. Nothing in Arturs code or your example contains anything that is applicable to the 3 bullet points I wrote: 1) Neither contain any mixin templates 2) None use {}() without some content to the body. 3) Both bodies using that syntax explicitly return strings.On Monday, 8 July 2013 at 22:41:41 UTC, JS wrote:Maybe you need to go tell Artur that he is wrong first before you bitch at me for being wrong... http://forum.dlang.org/thread/myalrxrrwoljxbboaymh forum.dlang.org Please, at least if you are going to bitch and talk down to me about writing valid source code at least know what you are talking about in the first place... module main; import std.stdio, std.cstream; template b() { enum b = { return "\"asdf\""; }(); pragma(msg, b); } int main(string[] argv) { auto f = (){ writeln("asd"); }; f(); writeln(mixin(b!())); din.getc(); return 0; }trying to use a lambda inside a sub template gives an error. mixin template a { template b() { enum b = { }(); } mixin(b!()); } gives the error in the subject, removing the nesting or using a function instead of a lamda produces no error, yet all are essentially semantically equivalent... just the lamda version requires less typing. (in fact, it would be nice to have a simplification of template b() = { ... }();)This belongs in D.learn. The code you provided is never going to give any "Function literals can't be class members" error, although it does have a lot of other things wrong with it. 1) The mixin template has no parameter list. 2) enum b = { }(); isn't valid without a function body. Did you mean (){} ? 3) and it definitely isn't going to return a string to work with mixin(); It helps to give code examples that are at least syntactically correct, if not immediately compilable. A correct and simplified test case of what I *think* you are talking about is this: mixin template A() { auto foo = (){ }; } class C { mixin A!(); } Error: delegate f977.C.A!().__lambda1 function literals cannot be class members Lambda function and delegate literals cannot be class members. Function literals can. I'm not entirely sure on the reason why, it's probably to do with context pointers.
Jul 09 2013