Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 26, 2011 Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
I'm only asking because I can't use it inside of a pragma(msg) call since CTFE can't do C-style variadic functions yet. Is `format` defined this way for performance reasons? (to avoid template bloat?) |
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On 2011-09-26 05:39, Andrej Mitrovic wrote: > I'm only asking because I can't use it inside of a pragma(msg) call > since CTFE can't do C-style variadic functions yet. Is `format` > defined this way for performance reasons? (to avoid template bloat?) std.string.format is using a D-style variadic parameter list. This would be a C-style variadic parameter list: extern (C) string format (int c, ...); It might just be an old function from D1 when template tuple parameters where not just that much. -- /Jacob Carlborg |
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 9/26/11, Jacob Carlborg <doob@me.com> wrote: > std.string.format is using a D-style variadic parameter list. The compiler disagrees with you: D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\string.d(2432): Error: function std.string.format C-style variadic functions are not yet implemented in CTFE L2432: string format(...) I don't see any other format() overloads in std.string. |
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On Mon, 26 Sep 2011 08:42:09 -0400, Andrej Mitrovic <andrej.mitrovich@gmail.com> wrote:
> On 9/26/11, Jacob Carlborg <doob@me.com> wrote:
>> std.string.format is using a D-style variadic parameter list.
>
> The compiler disagrees with you:
>
> D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\string.d(2432): Error:
> function std.string.format C-style variadic functions are not yet
> implemented in CTFE
>
> L2432:
> string format(...)
>
> I don't see any other format() overloads in std.string.
That's likely a bug. D variadic functions push the TypeInfo of each parameter onto the stack as well as the parameters themselves.
Unfortunately, it's probably just a wrong error message, I doubt D variadic parameters are supported in CTFE.
-Steve
|
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On 09/26/2011 07:42 AM, Andrej Mitrovic wrote:
> On 9/26/11, Jacob Carlborg <doob@me.com> wrote:
>> std.string.format is using a D-style variadic parameter list.
>
> The compiler disagrees with you:
>
> D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\string.d(2432): Error: function std.string.format C-style variadic functions are not yet implemented in CTFE
>
> L2432:
> string format(...)
>
> I don't see any other format() overloads in std.string.
std.metastrings.Format wouldn't be what you want, would it?
|
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On 2011-09-26 17:12, Steven Schveighoffer wrote: > On Mon, 26 Sep 2011 08:42:09 -0400, Andrej Mitrovic > <andrej.mitrovich@gmail.com> wrote: > >> On 9/26/11, Jacob Carlborg <doob@me.com> wrote: >>> std.string.format is using a D-style variadic parameter list. >> >> The compiler disagrees with you: >> >> D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\string.d(2432): Error: >> function std.string.format C-style variadic functions are not yet >> implemented in CTFE >> >> L2432: >> string format(...) >> >> I don't see any other format() overloads in std.string. > > That's likely a bug. D variadic functions push the TypeInfo of each > parameter onto the stack as well as the parameters themselves. > > Unfortunately, it's probably just a wrong error message, I doubt D > variadic parameters are supported in CTFE. > > -Steve Yes, that is not a C-style variadic function. -- /Jacob Carlborg |
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | On 9/26/11, Ellery Newcomer <ellery-newcomer@utulsa.edu> wrote:
> std.metastrings.Format wouldn't be what you want, would it?
>
Yep it is, Jonathan mentioned it above.
|
September 26, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | Hmm yea, the docs say so too. Sorry for the noise then. :) |
September 27, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | On 09/26/2011 11:15 AM, Andrej Mitrovic wrote:
> On 9/26/11, Ellery Newcomer <ellery-newcomer@utulsa.edu> wrote:
>> std.metastrings.Format wouldn't be what you want, would it?
>>
>
> Yep it is, Jonathan mentioned it above.
thunderbird hates me. second time I give an answer made redundant by orphaned subthread.
I'll counter by giving random unsolicited thoughts on Format:
don't use it for codegen (or any long format strings, I suppose). dmd
chokes on it very quickly.
format specifiers could use positional parameters or something. Last summer I actually wrote a Replace template to scratch that itch. dmd choked on it pretty quickly too.
|
September 27, 2011 Re: Why is std.string.format a c-style variadic function? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ellery Newcomer | Ellery Newcomer , dans le message (digitalmars.D.learn:29819), a écrit : > On 09/26/2011 11:15 AM, Andrej Mitrovic wrote: >> On 9/26/11, Ellery Newcomer <ellery-newcomer@utulsa.edu> wrote: >>> std.metastrings.Format wouldn't be what you want, would it? >>> >> >> Yep it is, Jonathan mentioned it above. > > thunderbird hates me. second time I give an answer made redundant by orphaned subthread. > I've got the same problem with most of Jonathan's posts. I use flrn, an obsure news reader that nobody here probably knows about, so I thought it was just me. It seems that the Reference field in Jonathan's posts are unusual and break threads in some news reader. Would anyone know a solution (either for Elley and me, or for Jonathan)? -- Christophe |
Copyright © 1999-2021 by the D Language Foundation