overloading operators for I/O

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Feb 15 14:52:20 PST 2007


renoX wrote:
> - a syntax 'a la Ruby' would permit to see better the resulting string:
> writef("x is %{vx}, y is %{vy}\n"); of course you could still specify 
> the format if you want: writef("x is %08x{vx}\n");

A syntax like this may be possible with string mixins. I'm pretty sure 
you could write that like this:
---
mixin(write!("x is %{vx}, y is %{vy}\n"));
---
and get away with it, given the proper 'write' template. It might not 
even be very difficult, it'd just need to find the %{} groups, parse 
them out and generate the proper call(s) to other functions. The backend 
could be writef, or Tango's Stdout.format or something custom-written.



More information about the Digitalmars-d mailing list