Re: Determine if CTFE or RT

2018-06-25 Thread Mr.Bingo via Digitalmars-d-learn
On Monday, 25 June 2018 at 10:49:26 UTC, Simen Kjærås wrote: On Monday, 25 June 2018 at 09:36:45 UTC, Martin Tschierschke wrote: I am not sure that I understood it right, but there is a way to detect the status of a parameter: My question was different, but I wished to get a ctRegex! or regex

Re: Determine if CTFE or RT

2018-06-25 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 25 June 2018 at 09:36:45 UTC, Martin Tschierschke wrote: I am not sure that I understood it right, but there is a way to detect the status of a parameter: My question was different, but I wished to get a ctRegex! or regex used depending on the expression: import std.regex:replace

Re: Determine if CTFE or RT

2018-06-25 Thread ag0aep6g via Digitalmars-d-learn
On 06/25/2018 07:47 AM, Mr.Bingo wrote: The docs say that CTFE is used only when explicit, I was under the impression that it would attempt to optimize functions if they could be computed at compile time. The halting problem has nothing to do with this. The ctfe engine already complains when on

Re: Determine if CTFE or RT

2018-06-25 Thread Martin Tschierschke via Digitalmars-d-learn
On Monday, 25 June 2018 at 08:05:53 UTC, Mr.Bingo wrote: On Monday, 25 June 2018 at 07:02:24 UTC, Jonathan M Davis wrote: On Monday, June 25, 2018 05:47:30 Mr.Bingo via Digitalmars-d-learn wrote: The problem then, if D can't arbitrarily use ctfe, means that there should be a way to force ctfe o

Re: Determine if CTFE or RT

2018-06-25 Thread Mr.Bingo via Digitalmars-d-learn
On Monday, 25 June 2018 at 07:02:24 UTC, Jonathan M Davis wrote: On Monday, June 25, 2018 05:47:30 Mr.Bingo via Digitalmars-d-learn wrote: The problem then, if D can't arbitrarily use ctfe, means that there should be a way to force ctfe optionally! If you want to use CTFE, then give an enum th

Re: Determine if CTFE or RT

2018-06-25 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 25, 2018 05:47:30 Mr.Bingo via Digitalmars-d-learn wrote: > The problem then, if D can't arbitrarily use ctfe, means that > there should be a way to force ctfe optionally! If you want to use CTFE, then give an enum the value of the expression you want calculated. If you want to do

Re: Determine if CTFE or RT

2018-06-24 Thread Mr.Bingo via Digitalmars-d-learn
On Monday, 25 June 2018 at 05:14:31 UTC, Jonathan M Davis wrote: On Monday, June 25, 2018 05:03:26 Mr.Bingo via Digitalmars-d-learn wrote: The compiler should be easily able to figure out that foo(3) can be precomputed(ctfe'ed) and do so. It can already do this, as you say, by forcing enum on i

Re: Determine if CTFE or RT

2018-06-24 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, June 25, 2018 05:03:26 Mr.Bingo via Digitalmars-d-learn wrote: > The compiler should be easily able to figure out that foo(3) can > be precomputed(ctfe'ed) and do so. It can already do this, as you > say, by forcing enum on it. Why can't the compiler figure it out > directly? The big pr

Re: Determine if CTFE or RT

2018-06-24 Thread Mr.Bingo via Digitalmars-d-learn
On Sunday, 24 June 2018 at 20:03:19 UTC, arturg wrote: On Sunday, 24 June 2018 at 19:10:36 UTC, Mr.Bingo wrote: On Sunday, 24 June 2018 at 18:21:09 UTC, rjframe wrote: On Sun, 24 Jun 2018 14:43:09 +, Mr.Bingo wrote: let is(CTFE == x) mean that x is a compile time constant. CTFE(x) convert

Re: Determine if CTFE or RT

2018-06-24 Thread arturg via Digitalmars-d-learn
On Sunday, 24 June 2018 at 19:10:36 UTC, Mr.Bingo wrote: On Sunday, 24 June 2018 at 18:21:09 UTC, rjframe wrote: On Sun, 24 Jun 2018 14:43:09 +, Mr.Bingo wrote: let is(CTFE == x) mean that x is a compile time constant. CTFE(x) converts a x to this compile time constant. Passing any compil

Re: Determine if CTFE or RT

2018-06-24 Thread Mr.Bingo via Digitalmars-d-learn
On Sunday, 24 June 2018 at 18:21:09 UTC, rjframe wrote: On Sun, 24 Jun 2018 14:43:09 +, Mr.Bingo wrote: let is(CTFE == x) mean that x is a compile time constant. CTFE(x) converts a x to this compile time constant. Passing any compile time constant essentially turns the variable in to a co

Re: Determine if CTFE or RT

2018-06-24 Thread Stefan Koch via Digitalmars-d-learn
On Sunday, 24 June 2018 at 18:21:09 UTC, rjframe wrote: On Sun, 24 Jun 2018 14:43:09 +, Mr.Bingo wrote: let is(CTFE == x) mean that x is a compile time constant. CTFE(x) converts a x to this compile time constant. Passing any compile time constant essentially turns the variable in to a co

Re: Determine if CTFE or RT

2018-06-24 Thread rjframe via Digitalmars-d-learn
On Sun, 24 Jun 2018 14:43:09 +, Mr.Bingo wrote: > let is(CTFE == x) mean that x is a compile time constant. CTFE(x) > converts a x to this compile time constant. Passing any compile time > constant essentially turns the variable in to a compile time > constant(effectively turns it in to a temp

Determine if CTFE or RT

2018-06-24 Thread Mr.Bingo via Digitalmars-d-learn
let is(CTFE == x) mean that x is a compile time constant. CTFE(x) converts a x to this compile time constant. Passing any compile time constant essentially turns the variable in to a compile time constant(effectively turns it in to a template with template parameter) void foo(size_t i) {