December 10, 2018
On 12/10/18 2:16 PM, Neia Neutuladh wrote:
> On Mon, 10 Dec 2018 19:35:16 +0100, Daniel Kozak wrote:
>> I do not see any problem with add one line in every function.
> 
> One line in every scope, rather:
> 
>      void foo()
>      {
>        mixin(interpSupport);
>        {
>          auto i = 10;
>          // doesn't work
>          writeln(interp!"i is $i");
>        }
>      }
> 

This is less of a problem, because it breaks and tells you why it breaks. Whereas the other silent hijacking of which symbol you're talking about could be more confusing.

People would likely just hoist those variables up to the outer scope rather than moving the mixin (I know I would).

Still one of the warts, though.

-Steve
December 10, 2018
On Monday, 10 December 2018 at 10:11:44 UTC, Daniel Kozak wrote:
> https://run.dlang.io/is/FbOnGI
>
> import std.stdio;
> template somefun()
> {
>      auto iterpolate(string s)()
>      {
>          //do some parsing
>          return mixin(s[1 .. $]);
>      }
> }
>
> enum enableInterpolate = "mixin somefun A; alias interpolate = A.iterpolate;";
>
> void main()
> {
>     mixin(enableInterpolate);
>     int a = 5;
>     iterpolate!("$a").writeln;
> }

The issue that I have with this is that users do not want to manually add the mixin to the code scope every time they want string interpolation and worry about bugs that they may run across due to the misuse of the mixin. Let the compiler do the heavy lifting.
December 13, 2018
On Monday, 10 December 2018 at 16:45:30 UTC, Steven Schveighoffer wrote:
> 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.

Was mangling of nested functions fixed?
1 2 3
Next ›   Last »