DIP 1027---String Interpolation---Format Assessment
Walter Bright
newshound2 at digitalmars.com
Mon Feb 24 21:10:04 UTC 2020
On 2/24/2020 12:19 PM, Steven Schveighoffer wrote:
> How can you possibly arrive at this conclusion? We lower to templates all the
> time.
The language is nowhere defined as lowering to specific templates. There are
indeed some lowerings to templates in the implementation of the language, but
those are NOT user defined templates, they are simply an implementation convenience.
> By this definition all operator overloading in D is AST macros.
Operator overloading is not supported for basic types. It's fundamentally
different from what was proposed for interpolated strings.
> Except that's not what's happening here. It's lowering to a template defined by
> the language, not the user. The user creates their own API (not language) by
> accepting such a template and unsurprisingly can react differently to different
> parameters to said function or template.
"creates their own API" => AST macros
> If you have an example that proves me wrong, I'd love to see it. How can this
> feature do something that is "like AST macros"?
Because the proposed templates modify the behavior of basic types. From the
discussion:
> i"$apples and ${%d}bananas"
> =>
> (__d_format_literal!(Format.init, " and ", Format("%d")),
apples, bananas)
More information about the Digitalmars-d-announce
mailing list