Re: Compile-time constness is waaay to strict!

2009-07-25 Thread asd
KennyTM~ Wrote: > It makes sense. A compile-time function must be executable in run time > as well. Which means both of the following must be meaningful. > > void main () { >auto s = readln(); >if (isEmptyString(s)) { ... } // Run time executed > } > > void main2 () { >static if (is

Re: Compile-time constness is waaay to strict!

2009-07-25 Thread KennyTM~
asd wrote: Daniel Keep Wrote: bool isEmptyString(string str) { static if (str == "") return true; It works if you use 'if' instead of 'static if', oddly. return false; } void main() { static if (isEmptyString("")) { int x = 1; } } test.d(5

Re: Compile-time constness is waaay to strict!

2009-07-25 Thread asd
Daniel Keep Wrote: > >> bool isEmptyString(string str) { > >>static if (str == "") return true; > > > > It works if you use 'if' instead of 'static if', oddly. > > > >>return false; > >> } > >> > >> void main() > >> { > >>static if (isEmptyString("")) > >>{ > >>

Re: Compile-time constness is waaay to strict!

2009-07-25 Thread Lars T. Kyllingstad
asd wrote: Jarrett Billingsley Wrote: Can you post more of your code? I've reduced it to this: bool isEmptyString(string str) { static if (str == "") return true; return false; } void main() { static if (isEmptyString("")) { i

Re: Compile-time constness is waaay to strict!

2009-07-25 Thread Daniel Keep
Jarrett Billingsley wrote: > On Fri, Jul 24, 2009 at 11:03 PM, asd wrote: >> Jarrett Billingsley Wrote: >> >>> Can you post more of your code? >> I've reduced it to this: >> >> >> bool isEmptyString(string str) { >>static if (str == "") return true; > > It works if you use 'if' instead of

Re: Compile-time constness is waaay to strict!

2009-07-24 Thread Jarrett Billingsley
On Fri, Jul 24, 2009 at 11:03 PM, asd wrote: > Jarrett Billingsley Wrote: > >> Can you post more of your code? > > I've reduced it to this: > > > bool isEmptyString(string str) { >        static if (str == "") return true; It works if you use 'if' instead of 'static if', oddly. >        return fa

Re: Compile-time constness is waaay to strict!

2009-07-24 Thread asd
Jarrett Billingsley Wrote: > Can you post more of your code? I've reduced it to this: bool isEmptyString(string str) { static if (str == "") return true; return false; } void main() { static if (isEmptyString("")) { int x = 1;

Re: Compile-time constness is waaay to strict!

2009-07-24 Thread Jarrett Billingsley
On Fri, Jul 24, 2009 at 8:27 PM, asd wrote: > I've got D2 code: > >> template ObjcMethodSelectorCheck(string sel, A...) { >>       const n = countMethodArguments(sel); > > and: > > pure static uint countMethodArguments(string name) { >                if (name.length == 0) return 0; >              

Compile-time constness is waaay to strict!

2009-07-24 Thread asd
I've got D2 code: > template ObjcMethodSelectorCheck(string sel, A...) { > const n = countMethodArguments(sel); and: pure static uint countMethodArguments(string name) { if (name.length == 0) return 0; if (name[0] == ':') return 1+countMethodArg