digitalmars.D - std.metastrings and Variadic CTFE funcs
- Bill Baxter (11/11) Nov 06 2009 To Don, Walter, or anyone else who knows:
- Daniel Keep (12/23) Nov 06 2009 I just wrote my own.
- Bill Baxter (16/38) Nov 06 2009 It just occurred to me when I woke up this morning that it should be
- Daniel Keep (3/9) Nov 06 2009 The license should be compatible with Boost; I changed it yesterday so
- grauzone (2/6) Nov 06 2009 You just have to wait until all D features are fully implemented in CTFE...
To Don, Walter, or anyone else who knows: How hard is it going to be to get variadic CTFE functions working? Or how hard would it be to get std.metastrings.Format should be a major workhorse of CTFE string functions, but it can't be because it's all done using template args. And I'm assuming it's a template because variadic CTFE funcs don't work. In general, it would be nice to have more std.string functions available (as CTFE-capable functions) in std.metastrings. Like Replace and IndexOf. I whipped up a quick version of those two based somewhat on std.strings' versions just now. --bb
Nov 06 2009
Bill Baxter wrote:To Don, Walter, or anyone else who knows: How hard is it going to be to get variadic CTFE functions working? Or how hard would it be to get std.metastrings.Format should be a major workhorse of CTFE string functions, but it can't be because it's all done using template args. And I'm assuming it's a template because variadic CTFE funcs don't work.I just wrote my own. http://github.com/DanielKeep/gb/blob/master/src/gb/ctfe/Format.d Takes metastrings.Format out back and beats it black and blue before putting a silly hat on its head and dropping a cream pie down the front of its trousers.In general, it would be nice to have more std.string functions available (as CTFE-capable functions) in std.metastrings. Like Replace and IndexOf. I whipped up a quick version of those two based somewhat on std.strings' versions just now.Again, I just add stuff as I need it. http://github.com/DanielKeep/gb/blob/master/src/gb/ctfe/String.d I remember Walter talking about how CTFE meant you wouldn't need distinct runtime and compile-time libraries. Oh, how I chuckle. -- Daniel
Nov 06 2009
On Fri, Nov 6, 2009 at 5:58 AM, Daniel Keep <daniel.keep.lists gmail.com> w= rote:Bill Baxter wrote:It just occurred to me when I woke up this morning that it should be possible to use a templated variadic function for Format instead of a template. And looks that like what you're doing. That's a much better approach. I guess the only down side is that the CTFE memory leaks still exists. But anyway, would you be willing to make your code available under the Boost license so it can be used in Phobos?To Don, Walter, or anyone else who knows: How hard is it going to be to get variadic CTFE functions working? Or how hard would it be to get std.metastrings.Format should be a major workhorse of CTFE string functions, but it can't be because it's all done using template args. And I'm assuming it's a template because variadic CTFE funcs don't work.I just wrote my own. http://github.com/DanielKeep/gb/blob/master/src/gb/ctfe/Format.d Takes metastrings.Format out back and beats it black and blue before putting a silly hat on its head and dropping a cream pie down the front of its trousers.Yeh, ok, but the point of this message was that it would be nice to have something better in Phobos so everyone doesn't have to roll their own.In general, it would be nice to have more std.string functions available (as CTFE-capable functions) in std.metastrings. =A0Like Replace and IndexOf. =A0I whipped up a quick version of those two based somewhat on std.strings' versions just now.Again, I just add stuff as I need it. http://github.com/DanielKeep/gb/blob/master/src/gb/ctfe/String.dI remember Walter talking about how CTFE meant you wouldn't need distinct runtime and compile-time libraries. Oh, how I chuckle.Yeh. It seems unlikely that things like throwing exceptions will be supported in CTFE any time soon. So it would be nice to have a collection of string processing functions that do work CTFE in std.metastrings. --bb
Nov 06 2009
Bill Baxter wrote:It just occurred to me when I woke up this morning that it should be possible to use a templated variadic function for Format instead of a template. And looks that like what you're doing. That's a much better approach. I guess the only down side is that the CTFE memory leaks still exists. But anyway, would you be willing to make your code available under the Boost license so it can be used in Phobos?The license should be compatible with Boost; I changed it yesterday so Eldar could use it for something.
Nov 06 2009
Daniel Keep wrote:I remember Walter talking about how CTFE meant you wouldn't need distinct runtime and compile-time libraries. Oh, how I chuckle.You just have to wait until all D features are fully implemented in CTFE.
Nov 06 2009