Re: Mixin Template: cannot mixin scope(exit)?

2013-01-15 Thread Nicolas Sicard
On Tuesday, 15 January 2013 at 11:19:50 UTC, mist wrote: I thought template itself should compile but its statement-like instantiation should not. The template shouldn't compile: the D grammar says that mixin templates inject declarations only. Hence the text of the error. By the way, if all

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-15 Thread mist
I thought template itself should compile but its statement-like instantiation should not. By the way, if all you want is to split out some generic statement block without using dirty string mixins, template functions with alias parameters may do. I.e. http://dpaste.1azy.net/68ad8133 Don't kn

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-15 Thread Nicolas Sicard
On Monday, 14 January 2013 at 06:26:33 UTC, 1100110 wrote: On 01/13/2013 11:35 PM, 1100110 wrote: Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Time) mixin TimeExecutio

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-14 Thread Jacob Carlborg
On 2013-01-14 11:44, mist wrote: What is the rationale behind this limitation? I'm not sure but it might have something to do with template mixins introduce a new scope or similar. -- /Jacob Carlborg

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-14 Thread 1100110
On 01/14/2013 04:44 AM, mist wrote: It appears that you cannot mixin *any* statement with scope([exit,success,etc]) in it. I have been rereading my copy of TDPL, and it states that mixin statements must be valid D code, and there can be multiple 'scope()' statements. Since "scope(exit) writeln

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-14 Thread mist
It appears that you cannot mixin *any* statement with scope([exit,success,etc]) in it. I have been rereading my copy of TDPL, and it states that mixin statements must be valid D code, and there can be multiple 'scope()' statements. Since "scope(exit) writeln();" is valid D code, and refuses t

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-14 Thread 1100110
On 01/14/2013 02:03 AM, Timon Gehr wrote: On 01/14/2013 07:26 AM, 1100110 wrote: On 01/13/2013 11:35 PM, 1100110 wrote: Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Ti

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-14 Thread Timon Gehr
On 01/14/2013 07:26 AM, 1100110 wrote: On 01/13/2013 11:35 PM, 1100110 wrote: Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Time) mixin TimeExecution("funcName"); mixin

Re: Mixin Template: cannot mixin scope(exit)?

2013-01-13 Thread 1100110
On 01/13/2013 11:35 PM, 1100110 wrote: Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Time) mixin TimeExecution("funcName"); mixin template TimeExecution(T) if(isSomeStri

Mixin Template: cannot mixin scope(exit)?

2013-01-13 Thread 1100110
Ok, I wish to create a standard timing system so that I can measure ~how long each function takes to execute. I wish to be able to place at the start of a function version(Time) mixin TimeExecution("funcName"); mixin template TimeExecution(T) if(isSomeString!T) { import std.stdio, std.date