Exactly Replicating a Function's Signature?

Jacob Carlborg doob at me.com
Wed Jan 19 09:40:38 PST 2011


On 2011-01-19 18:28, %u wrote:
>> Is this what you're looking for?:
>
> No. :)
> (Though you already found this out at the end!)
> I was looking for some way to keep the storage classes and any other (meta)data
> about the parameters that may be added in the future to the library. I have a
> feeling this might be a very big change in how DMD handles parameters, but without
> this feature, perfect redirection -- which I think is possible in C++0x -- would
> be impossible in D.

The ugly solution would be to do this:

void test (ref int a) { }

void main ()
{
     writeln(typeof(&test).stringof);
}

Which will print: "void function(ref int a)" and then parse out what you 
need.

> My suggestion would be that we treat "ref", "out", and "lazy" as type constructors
> rather than storage specifiers; that way, we could get rid of the concept of
> storage classes entirely, and it would unify the concept of references with other
> languages like C# and C++.
>
> How does this idea sound? :) (I think it's easier said than done, though...)


-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list