Mixin Expressions, can't evalutate string variable
Andrej Mitrovic
andrej.mitrovich at gmail.com
Fri Aug 6 18:24:34 PDT 2010
Actually I better report this, it might lead to unexpected behavior
otherwise. See, this will compile:
import std.stdio;
auto template_func(alias func, T...)(T args)
{
return func.mangleof;
}
void test() {}
unittest
{
writeln(template_func!(test, int)(1));
}
void main() { }
And this won't:
import std.stdio;
auto template_func(alias func, T...)(T args)
{
return func.mangleof;
}
void test(int x) {}
unittest
{
writeln(template_func!(test, int)(1));
}
void main() { }
(I've added a parameter to test()). The problem is the first code actually
called func, and succeeded silently since it takes no parameters. I don't
think this is an expected behavior?
On Sat, Aug 7, 2010 at 3:10 AM, Andrej Mitrovic
<andrej.mitrovich at gmail.com>wrote:
>
>
> On Fri, Aug 6, 2010 at 8:40 PM, Jonathan M Davis <jmdavisprog at gmail.com>wrote:
>
>> On Friday, August 06, 2010 08:08:03 Andrej Mitrovic wrote:
>> > I've already tried that. But .mangleof on an aliased symbol just returns
>> > "alias" as a string.
>>
>> That sounds like a bug report in the making.
>>
>> - Jonathan M Davis
>>
>
> No I was wrong, it won't allow me to use .mangleof on an alias of a
> function inside a template because that automatically calls the function
> (and that means I have to pass valid arguments to it). The mangledName!()
> template works just fine though. But I don't need mangled names, I was only
> using it as a workaround.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20100807/582ae791/attachment.html>
More information about the Digitalmars-d
mailing list