Two standard libraries?

Robert Fraser fraserofthenight at gmail.com
Mon Jul 16 11:19:05 PDT 2007


Regan Heath Wrote:

> >> For example:
> >>
> >> "{0} has {1} pieces in {2}"
> >>
> >> Could be:
> >>
> >> "{supplier} has {stock} pieces in {city}"
> >>
> >> and make the translator happy.
> > 
> > How would such identifiers be matched up with variadic arguments?
> 
> hmm.. Could it match the variable names with the inserts?
> 
> string supplier = "Bob";
> string city = "Someplace far far away";
> int stock = 5;
> 
> format("{supplier} has {stock} pieces in {city}",
>    supplier, city, stock);
> 
> Maybe with some more reflection features it could be possible.
> 
> Regan
> 
>
 
Well, not even scripting languages keep names of local variables in memory at runtime, so I assume you mean compile-time. That means that the localized properties would have to be known at compile time (via file imports, etc.), which, assuming you store every language in the executable, might lead to some code bloat and a not-so-nimble architecture. But if that's what you're going for, someone demonstrated a while back that this is already possible, via mixins, and will get a lot easier with macros. Search for PHP-style print or something like that (I'm too lazy & limited by BlackBerry bandwidth to  get you the exact link).



More information about the Digitalmars-d mailing list