Voldemort structs no longer work?
H. S. Teoh
hsteoh at quickfur.ath.cx
Sat Dec 15 11:49:44 PST 2012
On Sat, Dec 15, 2012 at 11:45:10AM -0800, H. S. Teoh wrote:
[...]
> Found the reference in TDPL, §7.1.9 (p.263):
>
> Nested structs embed the magic "frame pointer" that allows them
> to access outer values such as a and b in the example above.
> [...] If you want to define a nested struct without that
> baggage, just prefix struct with static in the definition of
> Local, which makes Local a regular struct and consequently
> prevents it from accessing a and b.
>
> Ironically enough, Andrei in the subsequent paragraph discourages the
> use of such nested structs, whereas Walter's article promotes the use of
> such Voldemort types as a "happy discovery". :)
>
> Anyway, filed a bug:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=9162
[...]
Also, according to http://dlang.org/struct.html:
A nested struct is a struct that is declared inside the scope of
a function or a templated struct that has aliases to local
functions as a template argument. Nested structs have member
functions. It has access to the context of its enclosing scope
(via an added hidden field).
T
--
If you compete with slaves, you become a slave. -- Norbert Wiener
More information about the Digitalmars-d
mailing list