[Issue 19638] Demos should not use auto

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 2 16:51:54 UTC 2019


https://issues.dlang.org/show_bug.cgi?id=19638

Seb <greeenify at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |greeenify at gmail.com
         Resolution|---                         |INVALID

--- Comment #1 from Seb <greeenify at gmail.com> ---
>  so I will need to forward declare the variable however I cannot do this because I do not know the type I should be using to declare because it has been obscured by the use of auto in the demo.

Are you aware of e.g. `typeof`?

---
auto r = 10.iota;
---

is equal to:

---
typeof(10.iota) r;
...
r = 10.iota;
---

I will close this as invalid, because:

- for many functions in Phobos one doesn't even now the type
- `auto` is easier to read (less visible space)
- `auto` is smarter as you don't need to change anything if you refactor code
(also good for copy&paste examples)

I encourage you to look up Voldemort types
(https://wiki.dlang.org/Voldemort_types) and post to the Learn group for more
questions

--


More information about the Digitalmars-d-bugs mailing list