What do you thing about this string interpolation idea
Steven Schveighoffer
schveiguy at gmail.com
Mon Dec 10 16:45:30 UTC 2018
On 12/10/18 11:36 AM, Aliak wrote:
> On Monday, 10 December 2018 at 16:27:03 UTC, Steven Schveighoffer wrote:
>> On 12/10/18 11:11 AM, aliak wrote:
>>> This is much better than having to mixin everywhere. A couple of things:
>>>
>>> 1) Can this be put in a module so that you don't have to
>>> mixin(enableInterpolation) but instead "import interp =
>>> std.interpolation;" or something similar?
>>
>> No, you need a local mixin. Doing that import just imports the
>> *symbol* into your namespace, but it doesn't give access to your
>> namespace to the symbol.
>>
>
> Au :(. Yeah that makes sense. Then I’m not sure I see how this improves
> things if it has to be mixed in to every scope you want to use
> interpolation for. The sparseness of interpolation might just make
> mixin(Interp!””)); more appealing.
The benefit is that you only have to mixin once, whereas the usage does
not require a mixin. It just goes next to your import statements.
However, multiple scopes may make this less appealing, as you would have
to mixin at any inner scope that has a variable you want to deal with.
But I plan to write some string interpolation libraries based on this,
would love to see a "better SQL" library for something like this.
Not sure if it mitigates the need for an interpolation DIP, as clearly
this is going to be compile-time intensive, where the cleverness is
stomped on by memory usage and slow compile times.
-Steve
More information about the Digitalmars-d
mailing list