I think a more appropriate word for that would be "hide", or maybe "freeze".<br><br>Here's another alternative, if you can call it that :p :<br><br>import std.stdio;<br><br>auto freeze(alias dg)()<br>
{<br> return cast(const) dg();<br>}<br><br>void main() {<br> auto aa = freeze!(<br> {<br> int[int] aa_;<br> foreach (i; 0 .. 10)<br> aa_[i] = i * i;<br><br> return aa_;<br> });<br>
<br> writeln(aa, " ", typeid(aa));<br>}<br><br>But that returns const(const(int)[int]).<br><br>I'm not sure if there's a way to hide a symbol, appart from introducing another scope with { }. That wouldn't work in this case, since you want a const type back. Perhaps using the "variant" type from Phobos could do the trick.. I haven't played with that yet.<br>
<br><div class="gmail_quote">On Wed, Aug 11, 2010 at 6:01 PM, bearophile <span dir="ltr"><<a href="mailto:bearophileHUGS@lycos.com">bearophileHUGS@lycos.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">> Here delete doesn't clean the aa_, it just removes the aa_ name from the local namespace.<br>
<br>
</div>It's similar to the #undef directive of C.<br>
<br>
Bye,<br>
<font color="#888888">bearophile<br>
</font></blockquote></div><br>