Re: rdmd takes 2-3 seconds on a first-run of a simple .d script

2019-05-26 Thread Jon Degenhardt via Digitalmars-d-learn
On Saturday, 25 May 2019 at 22:18:16 UTC, Andre Pany wrote: On Saturday, 25 May 2019 at 08:32:08 UTC, BoQsc wrote: I have a simple standard .d script and I'm getting annoyed that it takes 2-3 seconds to run and see the results via rdmd. Also please keep in mind there could be other factors

Extract code of function

2019-05-26 Thread Andrey via Digitalmars-d-learn
Hello, Is it possible to extract code of some function into string variable using CT reflextion? For example: int test(bool flag) { return flag ? 100 : getRandom(); } enum string code = GetFunctionCode!test; // "return flag ? 100 : getRandom();"

Re: Extract code of function

2019-05-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2019-05-26 19:46, Andrey wrote: Hello, Is it possible to extract code of some function into string variable using CT reflextion? For example: int test(bool flag) {     return flag ? 100 : getRandom(); } enum string code = GetFunctionCode!test; // "return flag ? 100 : getRandom();" No,

Re: Extract code of function

2019-05-26 Thread Dennis via Digitalmars-d-learn
On Sunday, 26 May 2019 at 18:14:23 UTC, Jacob Carlborg wrote: No, that's not possible. Some hacky solutions are possible by importing a source file as a string and parsing it manually. dglsl actually extracts D function code to put into glsl shaders. Here's the snippet. See:

Instantiate templated class at runtime

2019-05-26 Thread Aphex via Digitalmars-d-learn
I have been using Orange SerDes library for an application and have run in to a major hurdle. I have the need to SerDes a templated class. It seems Orange can only Serialize the class but when it attempts to deserialize it at runtime it cannot build the class. It represents the type in the

Re: Extract code of function

2019-05-26 Thread Aphex via Digitalmars-d-learn
On Sunday, 26 May 2019 at 17:46:35 UTC, Andrey wrote: Hello, Is it possible to extract code of some function into string variable using CT reflextion? For example: int test(bool flag) { return flag ? 100 : getRandom(); } enum string code = GetFunctionCode!test; // "return flag ? 100 :

Re: Impose structure on array

2019-05-26 Thread 9il via Digitalmars-d-learn
On Monday, 20 May 2019 at 12:09:02 UTC, Alex wrote: given some array, is there some way to easily impose structure on that array at runtime? void* data; auto x = cast(byte[A,B,C])data; X is then an AxBxC matrix. I'm having to compute the index myself and it just seems unnecessary. A and B

Re: Extract code of function

2019-05-26 Thread Andrey via Digitalmars-d-learn
On Sunday, 26 May 2019 at 18:21:23 UTC, Dennis wrote: On Sunday, 26 May 2019 at 18:14:23 UTC, Jacob Carlborg wrote: No, that's not possible. Some hacky solutions are possible by importing a source file as a string and parsing it manually. dglsl actually extracts D function code to put into