digitalmars.D - Compile time string manipulation caveats
- Hasan Aljudy (4/4) Feb 24 2007 I discovered that compile-time functions can't use non-static arrays ..
- Gregor Richards (3/8) Feb 24 2007 Uh, compile-time functions /can/ use dynamic arrays.
- Hasan Aljudy (15/25) Feb 24 2007 oh, sorry my mistake,
- Hasan Aljudy (2/3) Feb 24 2007 I mean compile time ..
I discovered that compile-time functions can't use non-static arrays .. implying that we can't use char[] which is a dynamic array. However, this is essential for any non-trivial string parsing (even for trivial ones, in fact), so how do we overcome this problem?
Feb 24 2007
Hasan Aljudy wrote:I discovered that compile-time functions can't use non-static arrays .. implying that we can't use char[] which is a dynamic array. However, this is essential for any non-trivial string parsing (even for trivial ones, in fact), so how do we overcome this problem?Uh, compile-time functions /can/ use dynamic arrays. - Gregor Richards
Feb 24 2007
Gregor Richards wrote:Hasan Aljudy wrote:oh, sorry my mistake, I had a piece of code which was refusing to be compile-time executed, I didn't see anything wrong with it, but then I saw this: ------------ expressions in the function may not: * use pointers, delegates, *** non-const arrays ***, structs, unions or classes ------------ and thought that was causing the problem ... It turned out that I had a line: if( result != "" ) which was causing the problem, I changed it to if( result.length > 0 ) and my function was executing at run-time now!I discovered that compile-time functions can't use non-static arrays .. implying that we can't use char[] which is a dynamic array. However, this is essential for any non-trivial string parsing (even for trivial ones, in fact), so how do we overcome this problem?Uh, compile-time functions /can/ use dynamic arrays. - Gregor Richards
Feb 24 2007
Hasan Aljudy wrote:and my function was executing at run-time now!I mean compile time ..
Feb 24 2007