On 12/8/21 7:36 PM, Salih Dincer wrote:
On Wednesday, 8 December 2021 at 23:47:07 UTC, Adam Ruppe wrote:
On Wednesday, 8 December 2021 at 23:43:48 UTC, Salih Dincer wrote:

I think you meant to say

void foo(string[] args...) {}

Not exactly...

```d
alias str = immutable(char)[];

void foo(str...)(str args) {
   foreach(ref a; args) {
     a.writeln('\t', typeof(a).stringof);
   }
   str s; // "Amazing! ---v";
   s.writeln(": ", typeof(s).stringof);
}
```


So what people are saying here (but not directly) is that `str` inside your template is a *different* symbol than `str` outside the template.

This code is *exactly the same* as the code above, it might help understand what is happening:

```d
alias foobar = immutable(char)[]; // this doesn't play into the template at all

void foo(str...)(str args) {
  foreach(ref a; args) {
    a.writeln('\t', typeof(a).stringof);
  }
  str s; // "Amazing! ---v";
  s.writeln(": ", typeof(s).stringof);
}
```

Just like the two `i` below refer to different things:

```d
int i;
void foo(int i) {
   writeln(i); // this is the function parameter i, not the module-level i
}
```

You may want to post what you want to achieve with your code, instead of examples of what you tried, and it may allow us to make things clearer. You are likely using the wrong construct to achieve your goals.

-Steve
  • T... args! Salih Dincer via Digitalmars-d-learn
    • Re: T... args! Adam Ruppe via Digitalmars-d-learn
      • Re: T... args! Salih Dincer via Digitalmars-d-learn
        • Re: T... args! Petar via Digitalmars-d-learn
        • Re: T... args! Steven Schveighoffer via Digitalmars-d-learn
          • Re: T... arg... Salih Dincer via Digitalmars-d-learn
            • Re: T..... Steven Schveighoffer via Digitalmars-d-learn
              • Re:... Tejas via Digitalmars-d-learn
                • ... Dennis via Digitalmars-d-learn
              • Re:... Salih Dincer via Digitalmars-d-learn
                • ... Tejas via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn

Reply via email to