std.metastrings and Variadic CTFE funcs

Bill Baxter wbaxter at gmail.com
Fri Nov 6 07:40:09 PST 2009


On Fri, Nov 6, 2009 at 5:58 AM, Daniel Keep <daniel.keep.lists at gmail.com> wrote:
>
>
> 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.

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?

>> 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

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.


> I 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



More information about the Digitalmars-d mailing list