I've already tried that. But .mangleof on an aliased symbol just returns "alias" as a string.<br><br><br><div class="gmail_quote">On Fri, Aug 6, 2010 at 10:44 AM, Jacob Carlborg <span dir="ltr"><<a href="mailto:doob@me.com">doob@me.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;">On 2010-08-05 23:50, Andrej Mitrovic 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">
On Thu, Aug 5, 2010 at 11:29 PM, Philippe Sigaud<br>
<<a href="mailto:philippe.sigaud@gmail.com" target="_blank">philippe.sigaud@gmail.com</a> <mailto:<a href="mailto:philippe.sigaud@gmail.com" target="_blank">philippe.sigaud@gmail.com</a>>> wrote:<br>
<br>
<br>
<br>
On Thu, Aug 5, 2010 at 22:24, Andrej Mitrovic<br></div><div class="im">
<<a href="mailto:andrej.mitrovich@gmail.com" target="_blank">andrej.mitrovich@gmail.com</a> <mailto:<a href="mailto:andrej.mitrovich@gmail.com" target="_blank">andrej.mitrovich@gmail.com</a>>> wrote:<br>
<br>
Thanks, Steven!<br>
<br>
You don't want to know what I'm up to :p.<br>
<br>
<br>
Yes, yes, wo do!<br>
<br>
<br>
I'm using some traits to find out what kind of parameters a<br>
function takes. I'm also using a demangler from phobos to find<br>
out the name of the function (But I can't find any<br>
straightforward way to get a name of a function without getting<br>
back "1D_5std_5funcName" etc, so I just take a hardcoded slice).<br>
<br>
<br>
You can get the name of an alias using __traits(identifier,<br>
aliasName), like this for example:<br>
<br>
template Name(alias a)<br>
{<br>
enum string Name = __traits(identifier, a);<br>
}<br>
<br>
int foo(int i) { return 0;}<br>
<br>
import std.stdio;<br>
void main()<br>
{<br>
writeln(Name!foo); // "foo", not "a".<br>
}<br>
<br>
<br>
As for demangling, how do you do to get mangled names in the first<br>
place?<br>
<br>
<br></div><div class="im">
I was using mangledName!() from std.straits. __traits works prefectly,<br>
Thanks!<br>
</div></blockquote>
<br>
You know there is a .mangleof property for all symbols.<br>
<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">
Anyway, I have a template function which takes as it's<br>
parameters a function (aliased to func), and some arguments<br>
(right now just one in my hardcoded code). It then creates a<br>
string which can be compiled via the mixin. It constructs the<br>
string by checking the parameter types of func, and for any ref<br>
or out parameter it detects it appends something like this to a<br>
string:<br>
"long var1; long var2; long var3; ".<br>
<br>
<br>
How can you know if a parameter is ref or out?<br>
I remember seeing something about it in Phobos svn, are you using it?<br>
<br>
<br></div><div class="im">
Not svn, it's in 2.047 (maybe in earlier ones as well) in std.traits:<br>
<br>
ParameterTypeTuple!(alias) - for the types<br>
ParameterStorageClassTuple!(alias) - for the storage class<br>
<br></div><div class="im">
So anyway, at the calling site I have this:<br>
<br>
mixin(unpack!(getTimes)(r"C:\\cookies"));<br>
<br>
getTimes() is a Phobos function with the signature:<br>
getTimes(in char[] name, out d_time ftc, out d_time fta, out<br>
d_time ftm)<br>
<br>
And now I automatically have var1, var2, and var3 at my disposal.<br>
<br>
<br>
That's fun :)<br>
<br>
<br>
It was just an exercise for fun but it's cool that things like<br>
this are possible in D. It would be nice if I could get the<br>
actual names of the parameters the function takes + the clear<br>
name of the function itself, that way I'd actually get back<br>
variables "ftc, fta, ftm" back)<br>
<br>
<br>
I'm pretty sure I saw some code to do this. But maybe that was a D1<br>
thing, using mangled names, too.<br>
in dsource/scrapple?<br>
<br>
Philippe<br>
<br>
<br></div><div class="im">
Dunno, I haven't been using D1 really (actually I tried it some years<br>
ago with Tango but it left me wanting more so I never stuck around<br>
much). But D2 is super-fun.<br>
<br>
<br>
<br>
</div></blockquote>
<br>
<br>
-- <br><font color="#888888">
/Jacob Carlborg<br>
</font></blockquote></div><br>