Re: Making sense out of scope and function calls

2022-11-14 Thread Dukc via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote: Why does only the latter sample compile? The former leads to the following warning: Are you using the `-preview=dip1000` compiler flag? I didn't manage to reproduce this in a simple example of my own. The closest I equivalent I

Re: Making sense out of scope and function calls

2022-11-13 Thread 0xEAB via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:36:48 UTC, Dennis wrote: Can you please provide a full example? I'm missing the definitions of _headers, hstring, values ```d /++ “HTTP message string” – short-hand for `const(char)[]``. $(SIDEBAR Not sure about the name. Would have

Re: Making sense out of scope and function calls

2022-11-13 Thread Dennis via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote: Why does only the latter sample compile? The former leads to the following warning: Can you please provide a full example? I'm missing the definitions of _headers, hstring, values, and I suspect there's at least one `@safe` annotation

Re: Making sense out of scope and function calls

2022-11-13 Thread Imperatorn via Digitalmars-d-learn
On Sunday, 13 November 2022 at 19:06:40 UTC, 0xEAB wrote: ```d struct Foo { /* … */ hstring[] getHeader(LowerCaseToken name) scope return { return _headers[name].values; } [...] There's an old saying "you can't make sense out of scope"

Making sense out of scope and function calls

2022-11-13 Thread 0xEAB via Digitalmars-d-learn
```d struct Foo { /* … */ hstring[] getHeader(LowerCaseToken name) scope return { return _headers[name].values; } hstring[] getHeader(hstring name)() scope return { enum token = LowerCaseToken.makeConverted(name); return this.getHeader(token); // line