Re: CTFE & code generators based on PEG grammars?

2019-04-07 Thread ag0aep6g via Digitalmars-d-learn
On 07.04.19 05:32, Alex wrote: readlin is not a CT function. You misinterpreted what I said. Yeah, bad example from me. This would probably have been better: auto v = "foo"; enum y = f(v); /* Error: variable v cannot be read at compile time */ Also, the `readln` example wasn't

Re: CTFE & code generators based on PEG grammars?

2019-04-07 Thread Alex via Digitalmars-d-learn
On Sunday, 7 April 2019 at 06:39:05 UTC, zabruk wrote: On Sunday, 7 April 2019 at 03:32:45 UTC, Alex wrote: just execute them at CT if possible(and the possibility simply is if the inputs are known at CT). imho, Bastiaan Veelo want to say about citate above: not just "if possible", but "only

Re: CTFE & code generators based on PEG grammars?

2019-04-07 Thread Robert M. Münch via Digitalmars-d-learn
On 2019-04-06 20:16:14 +, Bastiaan Veelo said: On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote: The idea is, that I can write a string (or maybe even a scope block?) in my DSL and use a CTFE grammer to transpile the code. Are you aware of Pegged[1]? It’s for exactly

Re: CTFE & code generators based on PEG grammars?

2019-04-07 Thread zabruk via Digitalmars-d-learn
On Sunday, 7 April 2019 at 03:32:45 UTC, Alex wrote: just execute them at CT if possible(and the possibility simply is if the inputs are known at CT). imho, Bastiaan Veelo want to say about citate above: not just "if possible", but "only if needed and possible"

Re: CTFE & code generators based on PEG grammars?

2019-04-06 Thread Alex via Digitalmars-d-learn
On Saturday, 6 April 2019 at 14:59:18 UTC, ag0aep6g wrote: On 06.04.19 16:19, Alex wrote: That is CTFE is CT RTFE where runtime functions are executed at compile time when the inputs are CT. You may have the right idea, but the last part of that sentence is wrong/misleading. CTFE happens

Re: CTFE & code generators based on PEG grammars?

2019-04-06 Thread Bastiaan Veelo via Digitalmars-d-learn
On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote: The idea is, that I can write a string (or maybe even a scope block?) in my DSL and use a CTFE grammer to transpile the code. Are you aware of Pegged[1]? It’s for exactly that. [1] http://code.dlang.org/packages/pegged

Re: CTFE & code generators based on PEG grammars?

2019-04-06 Thread ag0aep6g via Digitalmars-d-learn
On 06.04.19 16:19, Alex wrote: That is CTFE is CT RTFE where runtime functions are executed at compile time when the inputs are CT. You may have the right idea, but the last part of that sentence is wrong/misleading. CTFE happens when the result is required at CT. The inputs must be

Re: CTFE & code generators based on PEG grammars?

2019-04-06 Thread Alex via Digitalmars-d-learn
On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote: I like the idea of DSL which are transpiled into the target language that gets compiled or are interpreted at run-time. Since D is compiled, I would like to transpile the DSL to D at compile-time. The idea is, that I can write

Re: CTFE & code generators based on PEG grammars?

2019-04-06 Thread Seb via Digitalmars-d-learn
On Saturday, 6 April 2019 at 12:06:22 UTC, Robert M. Münch wrote: I like the idea of DSL which are transpiled into the target language that gets compiled or are interpreted at run-time. Since D is compiled, I would like to transpile the DSL to D at compile-time. The idea is, that I can write

CTFE & code generators based on PEG grammars?

2019-04-06 Thread Robert M. Münch via Digitalmars-d-learn
I like the idea of DSL which are transpiled into the target language that gets compiled or are interpreted at run-time. Since D is compiled, I would like to transpile the DSL to D at compile-time. The idea is, that I can write a string (or maybe even a scope block?) in my DSL and use a CTFE