Re: Function literals can't be class members

2013-07-09 Thread JS

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?


Re: Function literals can't be class members

2013-07-09 Thread Dicebot

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.


Re: Function literals can't be class members

2013-07-09 Thread John Colvin

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.


Re: Function literals can't be class members

2013-07-09 Thread JS

On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote:

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.



Thanks... I'll just keep posting in here then...



Re: Function literals can't be class members

2013-07-09 Thread JS

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:

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.


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/myalrxrrwoljxbboa...@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;
}



Re: Function literals can't be class members

2013-07-09 Thread John Colvin

On Tuesday, 9 July 2013 at 10:45:40 UTC, JS wrote:

On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote:

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.



Thanks... I'll just keep posting in here then...


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.


Re: Function literals can't be class members

2013-07-09 Thread John Colvin

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:

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.


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/myalrxrrwoljxbboa...@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;
}


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.


Re: Function literals can't be class members

2013-07-09 Thread Dicebot

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.


Re: Function literals can't be class members

2013-07-09 Thread Joseph Rushton Wakeling
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 :-)


Re: Function literals can't be class members

2013-07-09 Thread Maxim Fomin

On Tuesday, 9 July 2013 at 10:45:40 UTC, JS wrote:

On Tuesday, 9 July 2013 at 10:10:10 UTC, Dicebot wrote:

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.



Thanks... I'll just keep posting in here then...


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.


Function literals can't be class members

2013-07-08 Thread JS

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() = { ... }();)