😁
Try the 2nd usage, D is a very flexible language; moves towards
perfection!
```d
struct Sarma {
int i;
// mixin DownRange;
}
struct Foo(T) {
int[] array;
// 1. USAGE
auto opApply(scope int delegate(T) dg) {
foreach (ref e; array)
{
On Friday, 27 September 2024 at 20:28:21 UTC, H. S. Teoh wrote:
...
The reason for (2) is that in UFCS chains, the only thing you
really only care about is what kind of range it is that you're
dealing with, and maybe the element type. What exactly the
container type is, is unimportant, and in
Jonathan M Davis via Digitalmars-d-learn wrote:
Well, I don't think that auto is a particularly controversial topic among D
programmers...
Thank you Jonathan for that very detailed response.
This thread can end now unless others really feel the need to comment.
I got two outstanding responses
H. S. Teoh via Digitalmars-d-learn wrote:
In idiomatic D, you'd use `auto` when either (1) you don't care what the
type is, you just want whatever value you get to be shoved into a
variable, or (2) you *shouldn't* care what the type is, because your
code shouldn't be depending on it, e.g., when y
On Friday, September 27, 2024 2:13:45 PM MDT thinkunix via Digitalmars-d-learn
wrote:
> monkyyy via Digitalmars-d-learn wrote:
> > On Friday, 27 September 2024 at 04:23:32 UTC, thinkunix wrote:
> >> What about using 'auto' as the return type?
> >> I tried it and it seemed to work OK.
> >>
> >> Won
On Thursday, September 26, 2024 12:53:12 AM MDT Per Nordlöw via Digitalmars-d-
learn wrote:
> Should a function like
>
> ```d
> uint parseHex(in char ch) pure nothrow @safe @nogc {
> switch (ch) {
> case '0': .. case '9':
> return ch - '0';
> case 'a': .. case 'f':
> return 10 + c
On Fri, Sep 27, 2024 at 04:13:45PM -0400, thinkunix via Digitalmars-d-learn
wrote:
[...]
> I've seen a lot of "use auto everywhere" especially in C++ and was
> wondering where the D community stands on it's use. Is it generally
> favored or not?
>
> Personally, I think auto makes understanding c
monkyyy via Digitalmars-d-learn wrote:
On Friday, 27 September 2024 at 04:23:32 UTC, thinkunix wrote:
What about using 'auto' as the return type?
I tried it and it seemed to work OK.
Wondering if there are any good reasons to use auto,
or bad reasons why not to use auto here?
You have starte