Templates in classes => what is wrong?

Xan xancorreu at gmail.com
Tue Apr 17 08:42:27 PDT 2012


On Tuesday, 17 April 2012 at 15:30:36 UTC, Ali Çehreli wrote:
> On 04/17/2012 08:17 AM, Xan wrote:
>> Off-topic, could can I define toString having this structure:
>>
>> <Name of the function> (versió <version number>): <Domain> -> 
>> <Range>,
>> <code of the function>
>>
>> ?
>>
>> (For example, in https://gist.github.com/2394274 I want that 
>> Doblar
>> displays as:
>> Doblar (versió 1): int -> int, { return 2 * a; }
>>
>>
>> Thanks a lot,
>> Xan.
>
> std.string.format is easy:
>
>     format("%s%s", 42, "hello");
>
> Ali

How to get the "code" of a function or delegate

|___string toString() {
|___|___return format("%s (versió %s): Domini -> Recorregut, 
%s(x) = %s", nom, versio, nom, &funcio);

|___}

does not produce the desired result and &funcio without ampersand 
produces me an error.

So, my doubts are:
given a function:

- how can I get the domain
- how can I get the range
- how can I get the code of the function?

See https://gist.github.com/2394274



More information about the Digitalmars-d-learn mailing list