September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On 04/09/2016 4:14 PM, Stefan Koch wrote:
> On Sunday, 4 September 2016 at 04:10:29 UTC, rikki cattermole wrote:
>> On 04/09/2016 2:08 PM, Stefan Koch wrote:
>>> On Sunday, 4 September 2016 at 02:06:55 UTC, Stefan Koch wrote:
>>>> This works already.
>>>> Anything placed in a debug {} block will be considered pure regardless.
>>>
>>> Opps your comment was about the debate.
>>> I would say that __ctfeWriteln and __ctfeTicksMs should not work outside
>>> of debug.
>>
>> Can we have writeln and writefln call into it if __ctfe is true?
>> Just so that we have got some consistency between runtime and CTFE usage.
>
> No!
> writeln and __ctfeWriteln are to be regarded as completely different
> things.
> __ctfeWriteln is a debugging tool only!
> It should not be used in any production code.
void writeln(T...)(T args) {
if (__ctfe){
debug {
__ctfeWriteln(args);
}
} else {
// ... current implementation
}
}
Are you sureeeee?
|
September 03, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Sunday, September 04, 2016 16:24:34 rikki cattermole via Digitalmars-d wrote:
> On 04/09/2016 4:14 PM, Stefan Koch wrote:
> > On Sunday, 4 September 2016 at 04:10:29 UTC, rikki cattermole wrote:
> >> On 04/09/2016 2:08 PM, Stefan Koch wrote:
> >>> On Sunday, 4 September 2016 at 02:06:55 UTC, Stefan Koch wrote:
> >>>> This works already.
> >>>> Anything placed in a debug {} block will be considered pure regardless.
> >>>
> >>> Opps your comment was about the debate.
> >>> I would say that __ctfeWriteln and __ctfeTicksMs should not work outside
> >>> of debug.
> >>
> >> Can we have writeln and writefln call into it if __ctfe is true?
> >> Just so that we have got some consistency between runtime and CTFE usage.
> >
> > No!
> > writeln and __ctfeWriteln are to be regarded as completely different
> > things.
> > __ctfeWriteln is a debugging tool only!
> > It should not be used in any production code.
>
> void writeln(T...)(T args) {
> if (__ctfe){
> debug {
> __ctfeWriteln(args);
> }
> } else {
> // ... current implementation
> }
> }
>
> Are you sureeeee?
He didn't say that it _couldn't_ be done. He said that it _shouldn't_ be done.
- Jonathan M Davis
|
September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On 04/09/2016 4:31 PM, Jonathan M Davis via Digitalmars-d wrote:
> On Sunday, September 04, 2016 16:24:34 rikki cattermole via Digitalmars-d
> wrote:
>> On 04/09/2016 4:14 PM, Stefan Koch wrote:
>>> On Sunday, 4 September 2016 at 04:10:29 UTC, rikki cattermole wrote:
>>>> On 04/09/2016 2:08 PM, Stefan Koch wrote:
>>>>> On Sunday, 4 September 2016 at 02:06:55 UTC, Stefan Koch wrote:
>>>>>> This works already.
>>>>>> Anything placed in a debug {} block will be considered pure regardless.
>>>>>
>>>>> Opps your comment was about the debate.
>>>>> I would say that __ctfeWriteln and __ctfeTicksMs should not work outside
>>>>> of debug.
>>>>
>>>> Can we have writeln and writefln call into it if __ctfe is true?
>>>> Just so that we have got some consistency between runtime and CTFE usage.
>>>
>>> No!
>>> writeln and __ctfeWriteln are to be regarded as completely different
>>> things.
>>> __ctfeWriteln is a debugging tool only!
>>> It should not be used in any production code.
>>
>> void writeln(T...)(T args) {
>> if (__ctfe){
>> debug {
>> __ctfeWriteln(args);
>> }
>> } else {
>> // ... current implementation
>> }
>> }
>>
>> Are you sureeeee?
>
> He didn't say that it _couldn't_ be done. He said that it _shouldn't_ be
> done.
>
> - Jonathan M Davis
I wrote that code to prove that it could be used only for debugging purposes, which is Stefan's argument.
|
September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan M Davis | On Sunday, 4 September 2016 at 04:31:09 UTC, Jonathan M Davis wrote:
>
> He didn't say that it _couldn't_ be done. He said that it _shouldn't_ be done.
>
> - Jonathan M Davis
Yes exactly.
|
September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Sunday, 4 September 2016 at 04:35:15 UTC, rikki cattermole wrote:
> void writeln(T...)(T args) {
> if (__ctfe){
> debug {
> __ctfeWriteln(args);
> }
> } else {
> // ... current implementation
> }
> }
That will not work.
The signature is void __ctfeWriteln(const string s)
|
September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On 9/4/16 6:10 AM, rikki cattermole wrote:
> On 04/09/2016 2:08 PM, Stefan Koch wrote:
>> On Sunday, 4 September 2016 at 02:06:55 UTC, Stefan Koch wrote:
>>> This works already.
>>> Anything placed in a debug {} block will be considered pure regardless.
>>
>> Opps your comment was about the debate.
>> I would say that __ctfeWriteln and __ctfeTicksMs should not work outside
>> of debug.
>
> Can we have writeln and writefln call into it if __ctfe is true?
> Just so that we have got some consistency between runtime and CTFE usage.
Yes, that's the natural way. __ctfeWriteln is really removing a limitation of writeln. -- Andrei
|
September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On 9/4/16 6:14 AM, Stefan Koch wrote:
> writeln and __ctfeWriteln are to be regarded as completely different
> things.
> __ctfeWriteln is a debugging tool only!
> It should not be used in any production code.
Well I'm not sure how that would be reasonably enforced. -- Andrei
|
September 04, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrei Alexandrescu | On Sunday, 4 September 2016 at 12:38:05 UTC, Andrei Alexandrescu wrote:
> On 9/4/16 6:14 AM, Stefan Koch wrote:
>> writeln and __ctfeWriteln are to be regarded as completely different
>> things.
>> __ctfeWriteln is a debugging tool only!
>> It should not be used in any production code.
>
> Well I'm not sure how that would be reasonably enforced. -- Andrei
One could enforce it by defining it inside a version or debug block.
The reason I do not want to see this in production code is as follows:
In the engine I am working on, communication between it and the rest of dmd is kept to a minimum, because :
"The new CTFE engine abstracts away everything into bytecode,
there is no guarantee that the bytecode-evaluator is run in the same process or even on the same machine."
|
September 06, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Sunday, 4 September 2016 at 04:24:34 UTC, rikki cattermole wrote:
> void writeln(T...)(T args) {
> if (__ctfe){
> debug {
> __ctfeWriteln(args);
> }
> } else {
> // ... current implementation
> }
> }
>
> Are you sureeeee?
any usage example?
consider a normal usage:
writeln("done.");
I just want a runtime output. how can I tell the compiler not to print "done." at compile time?
|
September 06, 2016 Re: CompileTime performance measurement | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On Sunday, 4 September 2016 at 19:36:16 UTC, Stefan Koch wrote: > On Sunday, 4 September 2016 at 12:38:05 UTC, Andrei Alexandrescu wrote: >> On 9/4/16 6:14 AM, Stefan Koch wrote: >>> writeln and __ctfeWriteln are to be regarded as completely different >>> things. >>> __ctfeWriteln is a debugging tool only! >>> It should not be used in any production code. >> >> Well I'm not sure how that would be reasonably enforced. -- Andrei > > One could enforce it by defining it inside a version or debug block. > The reason I do not want to see this in production code is as follows: > > In the engine I am working on, communication between it and the rest of dmd is kept to a minimum, because : > > "The new CTFE engine abstracts away everything into bytecode, > there is no guarantee that the bytecode-evaluator is run in the same process or even on the same machine." An alternative might be, to save your ctfe values in an static array and output them on startup of the compiled program. Same idea is used in vibe.d to make a caching of the templates evaluation possible. See: http://code.dlang.org/packages/diet-ng Experimental HTML template caching |
Copyright © 1999-2021 by the D Language Foundation