On Thu, 30 Oct 2014 09:46:48 -0700 "H. S. Teoh via Digitalmars-d" <[email protected]> wrote:
> > i recently wrote a very simple static 'writef', which genertes mixin > > with calls to posix `write()` and i really like it. nothing serious, > > though, and not very clear code, but it was fun to do a bit of > > functional programming again. ;-) > I saw that. Do you think it might be extendible enough to replace > std.stdio.writef? hm... with some work i'm pretty sure it will do. i added only the things i need, but it is generic enough to process anything you want. it can be simplified a little, but the basic mechanics are ok, i think. it is basically state machine which parses all necessary modifier arguments and then just going to "write-argument" state. i even passing the modifier there, so "write-argument" can do any magic you want. sure, it needs alot of work to fully replace current writef, but it's mostly writing missing formatters. i even think that with some little change user will be able to supply his own formating templates, so it can be extended almost like `format()`. i.e. user will be able to define states like "write-spec-x", "write-spec-d" and so on. and with another little change it can be made to use user-specified state to generate mixin code for writing arguments, so it can call any function user wants in the end. this is the beauty of state machine approach. ;-)
signature.asc
Description: PGP signature
