Thread overview | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
August 01, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
On 8/1/12, Walter Bright <walter@digitalmars.com> wrote: > http://ftp.digitalmars.com/dmd2beta.zip So it says here: "format's current implementation is scheduled for replacement in November 2012. It will then be replaced with xformat's implementation. This will be seamless for most code, but it will make it so that the only argument that can be a format string is the first one, so any code which uses multiple format strings will break." Other than that are there any other scheduled changes to format's behavior? It says format will eventually use xformat, but I don't really know how format is different than xformat right now. _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On Wed, Aug 1, 2012 at 11:54 PM, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote: > Other than that are there any other scheduled changes to format's behavior? It says format will eventually use xformat, but I don't really know how format is different than xformat right now. xformat is a template, in contrast to format being a plain variadic function. This, and the format string issue mentioned in the changelog. Other than that, there might be subtle differences because the underlying formatting code changed (now the same as e.g. for writefln). For example, I'd expect (without actually having tested it) that %s for xformat will »pretty-print« enum members instead of just printing the raw integer values, because the type information is now available as a template parameter. David _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On Thu, Aug 2, 2012 at 12:13 AM, David Nadlinger <code@klickverbot.at> wrote: > On Wed, Aug 1, 2012 at 11:54 PM, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote: >> Other than that are there any other scheduled changes to format's behavior? It says format will eventually use xformat, but I don't really know how format is different than xformat right now. > > xformat is a template, in contrast to format being a plain variadic function. This, and the format string issue mentioned in the changelog. > > Other than that, there might be subtle differences because the underlying formatting code changed (now the same as e.g. for writefln). For example, I'd expect (without actually having tested it) that %s for xformat will »pretty-print« enum members instead of just printing the raw integer values, because the type information is now available as a template parameter. > > David I can confirm this. It is in fact exactly why I want the templated version... Regards, Alex _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Nadlinger | On 8/2/12, David Nadlinger <code@klickverbot.at> wrote: > For example, I'd expect (without actually having tested it) > that %s for xformat will »pretty-print« enum members instead of just > printing the raw integer values, because the type information is now > available as a template parameter. Oh that's pretty cool. This also means CTFE will work for format (since it currently doesn't with the variadic version). I would have used xformat all along but I didn't realize it exists. :) _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | Yeah, Phobos often has that problem. Undocumented functions and modules that don't exist because you don't know they exist. import std.schrodinger; bool alive = box.open(); assert(alive && !alive); :P -Bernard. On Thu, 2 Aug 2012, Andrej Mitrovic wrote: > I would have used xformat all along but I didn't realize it exists. :) _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bernard Helyer | On 8/2/12, Bernard Helyer <b.helyer@gmail.com> wrote: > import std.schrodinger; > bool alive = box.open(); > assert(alive && !alive); > > :P Make it 'auto' and it might just work. :p _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On 8/2/12, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote: > Make it 'auto' and it might just work. :p struct box { T opCast(T : bool)() { static T state; state = !state; return state; } static auto open() { return typeof(this)(); } } void main() { auto alive = box.open(); assert(alive && !alive); } _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 02, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | I think we need a range interface if people want to open multiple boxes at once. On Thu, 2 Aug 2012, Andrej Mitrovic wrote: > On 8/2/12, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote: >> Make it 'auto' and it might just work. :p > > struct box > { > T opCast(T : bool)() > { > static T state; > state = !state; > return state; > } > > static auto open() > { > return typeof(this)(); > } > } > > void main() > { > auto alive = box.open(); > assert(alive && !alive); > } > _______________________________________________ > dmd-beta mailing list > dmd-beta@puremagic.com > http://lists.puremagic.com/mailman/listinfo/dmd-beta > _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
August 01, 2012 Re: [dmd-beta] std.format scheduled changes | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On Wednesday, August 01, 2012 23:54:50 Andrej Mitrovic wrote: > On 8/1/12, Walter Bright <walter@digitalmars.com> wrote: > > http://ftp.digitalmars.com/dmd2beta.zip > > So it says here: > "format's current implementation is scheduled for replacement in > November 2012. It will then be replaced with xformat's implementation. > This will be seamless for most code, but it will make it so that the > only argument that can be a format string is the first one, so any > code which uses multiple format strings will break." > > Other than that are there any other scheduled changes to format's behavior? It says format will eventually use xformat, but I don't really know how format is different than xformat right now. The key thing is that xformat should be identical to writef, so it'll be much more consistent. I don't know what all of the little details are though. The breaking change (and why format's implementation wasn't just replaced without saying much abouet it) is that only the first string is treated as a format string with xformat, whereas apparently format treats _all_ strings as format strings. There may be some slight differences here and there, but for the most part, the change should be transparent. - Jonathan M Davis _______________________________________________ dmd-beta mailing list dmd-beta@puremagic.com http://lists.puremagic.com/mailman/listinfo/dmd-beta |
Copyright © 1999-2021 by the D Language Foundation