I'm trying to write basic compile-time function:
string usedForMixin()
{
int n=0;
/* do stuff */
return "int x = " ~ std.metastrings.ToString!(n) ~ ";";
}
However I'm getting:
/usr/local/bin/../src/phobos/std/metastrings.d(104): Error: expression
cast(long)n is not a valid template value arg
> >> n < 0L is not constant or does not evaluate to a bool
> >> (D2, OS X)
> >>
> > That's because n isn't a compile-time constant. You can't instantiate
> > a template with runtime variables.
> >
>
> that includes "runtime variables" used in CTFE (this is because CTFE
> functions
> are also
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
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;
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(""))
> >>{
> >>
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
Jeremie Pelletier Wrote:
> There's a huge difference between complex code and long code, especially in
> compiled languages. Those 8 lines in your code are not convenient in that you
> don't get what they do on first sight. Declaring your things separately and
> then registering the closures to
Marianne Gagnon Wrote:
> OS X uses \n. \r dates from OS 9 (see http://en.wikipedia.org/wiki/Newline)
>
> As simple as that ;)
IMHO \r as line separator and MacRoman encoding should be killed with fire.
I've had too much trouble with these OS9isms generated by some apps that tried
to be nice.
Walter Bright Wrote:
> >> 2. Optimizer collects the info, but ignores this, because people are
> >> annoyed by false positives.
clang analyzer tries to avoid false positives very hard. To the point that
every error message has link for sending a bug report.
> The problem crops up when there ar
import std.stdio;
void main()
{
writef("Hello world\n");
}
dmd -run test.d gives:
Process: test [1703]
Path:/Users/username/Desktop/test
Identifier: test
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: dmd [1698]
Date/Time: 2009
forgot to add it's freshly downloaded dmd v2.035.
Andrei Alexandrescu Wrote:
> > Why would having one chunk of code get checked for calls to the GC and
> > another not be any more complicated than mixing
> > malloc/free+add/removeRoot with normal GC? I'm beginning to wonder if
> > I'm calling for something different than other people are.
> >
12 matches
Mail list logo