Literals - Was: Re: Remove complex and imaginary types?

Aarti_pl aarti at interia.pl
Mon Jan 7 00:31:22 PST 2008


Don Clugston pisze:
 > But a solution to the literal problem would be impressive.

Interesting... So it seems that its time for user defined literals? I 
saw another post in D.learn about big int literals. Also it would much 
nicer to initialize Date with human readable format....

Maybe something like this:

---

// l denotes literal or even without l{}
Date date = l{2008-01-07};

---
class Date {
	Date literal(string) {
		Date result;
		//... do the job on compile time:
		//parse and create proper class
		return result
	}
}

---

... when class defines compile time constructor function it tries to 
apply it for user literal.

Just quick idea without deeper analysis...

What do you think?

BR
Marcin Kuszczak



More information about the Digitalmars-d mailing list