When a variable is passed into a function, is its name kept somewhere for the function to acceess
DLangLearner via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 10 06:51:16 PST 2015
On Tuesday, 10 November 2015 at 14:22:49 UTC, Gary Willoughby
wrote:
> On Tuesday, 10 November 2015 at 14:14:33 UTC, DlangLearner
> wrote:
>> Please enlighten me if this can be done, thanks.
>
> If i understand you, you could use a templated function:
>
> import std.stdio;
>
> void foo(alias a)()
> {
> writefln("%s was passed in.", a.stringof);
> }
>
> void main(string[] args)
> {
> auto bar = "bar";
> foo!(bar);
> }
This is what I want. Thank you so much, this is a really elegant
solution.
More information about the Digitalmars-d-learn
mailing list