DIP 1027---String Interpolation---Format Assessment
Steven Schveighoffer
schveiguy at gmail.com
Mon Feb 24 20:19:46 UTC 2020
On 2/24/20 2:35 PM, Walter Bright wrote:
> Having the compiler lower string interpolation to some hidden template
> is - AST macros. We're not doing AST macros.
How can you possibly arrive at this conclusion? We lower to templates
all the time. By this definition all operator overloading in D is AST
macros. This means all the operations on associative arrays are AST
macros. array dup and idup -- AST macro. destroy is an AST macro.
>
> Hidden user-defined semantics are not for D. Every language I'm familiar
> with that supports it wound up with users creating their own completely
> undocumented personal language that nobody else can use or has the
> remotest interest in using.
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.
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"?
> If someone sees an i"abc" in the source code, they should be able to
> look in the language spec and know exactly what it does. They should not
> have to go trolling through imports looking for the definition of some
> template they never heard of.
I don't know where to begin here. The very argument rebuts itself -- The
reason you look in the spec is to find out about the type of an
interpolated string. Then you've heard of it. Are we supposed to only
implement features that people have heard of before reading the spec?
How would they have heard of it if they don't read the spec? Why do they
have to go "trolling through imports" (whatever that means -- this
template will be in object.d), and read the implementation? I mean,
people compare 2 objects all the time without reading the definition for
object.opEquals, I'm sure they could manage understanding that there's
something different about interpolated strings, and still use writefln
with them.
This whole response continues to imply that we do not understand each
other's point of view.
-Steve
More information about the Digitalmars-d-announce
mailing list