Thread overview | ||||||
---|---|---|---|---|---|---|
|
February 24, 2007 Compile time string manipulation caveats | ||||
---|---|---|---|---|
| ||||
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? |
February 24, 2007 Re: Compile time string manipulation caveats | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hasan Aljudy | 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
|
February 25, 2007 Re: Compile time string manipulation caveats | ||||
---|---|---|---|---|
| ||||
Posted in reply to Gregor Richards |
Gregor Richards wrote:
> 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
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!
|
February 25, 2007 Re: Compile time string manipulation caveats | ||||
---|---|---|---|---|
| ||||
Posted in reply to Hasan Aljudy |
Hasan Aljudy wrote:
> and my function was executing at run-time now!
I mean compile time ..
|
Copyright © 1999-2021 by the D Language Foundation