www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - DMD metaprogramming enhancement

reply Suleyman <sahmi.soulaimane gmail.com> writes:
Hello everyone,

I am happy to announce that in the next DMD release you will be 
able to more freely enjoy your metaprograming experience now that 
a long-standing limitation has been lifted.

You can now instantiate local and member templates with local 
symbols.

Example:
---
struct S
{
     private int _m;
     void exec(alias fun)()
     {
         fun(_m);
     }
}

unittest
{
     int localVar;

     void set(int i)
     {
         localVar = i;
     }

     auto obj = S(10);
     obj.exec!set();   // no error or warning

     assert(localVar == 10);
}
---

I hope you enjoy!
Apr 25
next sibling parent reply "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Thu, Apr 25, 2019 at 11:41:32PM +0000, Suleyman via Digitalmars-d-announce
wrote:
 Hello everyone,
 
 I am happy to announce that in the next DMD release you will be able
 to more freely enjoy your metaprograming experience now that a
 long-standing limitation has been lifted.
 
 You can now instantiate local and member templates with local symbols.
[...] That's very nice. Which PR was it that implemented this? T -- Век живи - век учись. А дураком помрёшь.
Apr 25
parent Suleyman <sahmi.soulaimane gmail.com> writes:
On Friday, 26 April 2019 at 00:12:06 UTC, H. S. Teoh wrote:
 That's very nice.  Which PR was it that implemented this?


 T
This one https://github.com/dlang/dmd/pull/9282.
Apr 25
prev sibling next sibling parent Aliak <something something.com> writes:
On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:
 Hello everyone,

 I am happy to announce that in the next DMD release you will be 
 able to more freely enjoy your metaprograming experience now 
 that a long-standing limitation has been lifted.

 You can now instantiate local and member templates with local 
 symbols.

 Example:
 ---
 struct S
 {
     private int _m;
     void exec(alias fun)()
     {
         fun(_m);
     }
 }

 unittest
 {
     int localVar;

     void set(int i)
     {
         localVar = i;
     }

     auto obj = S(10);
     obj.exec!set();   // no error or warning

     assert(localVar == 10);
 }
 ---

 I hope you enjoy!
Noice! Finally indeed. thank you! :D
Apr 25
prev sibling next sibling parent reply Simen =?UTF-8?B?S2rDpnLDpXM=?= <simen.kjaras gmail.com> writes:
On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:
 Hello everyone,

 I am happy to announce that in the next DMD release you will be 
 able to more freely enjoy your metaprograming experience now 
 that a long-standing limitation has been lifted.

 You can now instantiate local and member templates with local 
 symbols.

 Example:
 ---
 struct S
 {
     private int _m;
     void exec(alias fun)()
     {
         fun(_m);
     }
 }

 unittest
 {
     int localVar;

     void set(int i)
     {
         localVar = i;
     }

     auto obj = S(10);
     obj.exec!set();   // no error or warning

     assert(localVar == 10);
 }
 ---

 I hope you enjoy!
You have no idea how happy I am to hear this has been fixed! So many of my designs have been hamstrung by 5710, and it's been around since the dawn of time. -- Simen
Apr 25
next sibling parent reply Simen =?UTF-8?B?S2rDpnLDpXM=?= <simen.kjaras gmail.com> writes:
On Friday, 26 April 2019 at 06:29:04 UTC, Simen Kjærås wrote:
 On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:
 Hello everyone,

 I am happy to announce that in the next DMD release you will 
 be able to more freely enjoy your metaprograming experience 
 now that a long-standing limitation has been lifted.

 You can now instantiate local and member templates with local 
 symbols.

 Example:
 ---
 struct S
 {
     private int _m;
     void exec(alias fun)()
     {
         fun(_m);
     }
 }

 unittest
 {
     int localVar;

     void set(int i)
     {
         localVar = i;
     }

     auto obj = S(10);
     obj.exec!set();   // no error or warning

     assert(localVar == 10);
 }
 ---

 I hope you enjoy!
You have no idea how happy I am to hear this has been fixed! So many of my designs have been hamstrung by 5710, and it's been around since the dawn of time.
BTW, at least two people have promised money outside BountySource to have 5710 fixed: https://forum.dlang.org/post/gjzrklkxfmgjjdforbrs forum.dlang.org -- Simen
Apr 25
parent Meta <jared771 gmail.com> writes:
On Friday, 26 April 2019 at 06:34:26 UTC, Simen Kjærås wrote:
 BTW, at least two people have promised money outside 
 BountySource to have 5710 fixed:
 https://forum.dlang.org/post/gjzrklkxfmgjjdforbrs forum.dlang.org

 --
   Simen
And my offer still stands. Suleyman, do you have an email address I can contact you at to arrange payment?
Apr 27
prev sibling parent Aliak <something something.com> writes:
On Friday, 26 April 2019 at 06:29:04 UTC, Simen Kjærås wrote:
 On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:
 [...]
You have no idea how happy I am to hear this has been fixed! So many of my designs have been hamstrung by 5710, and it's been around since the dawn of time. -- Simen
Boh, there’s a revert under discussion :( - https://github.com/dlang/dmd/pull/9702 ( not merged yet but 🤷‍♂️)
Apr 27
prev sibling parent Greatsam4sure <greatsam4sure gmail.com> writes:
On Thursday, 25 April 2019 at 23:41:32 UTC, Suleyman wrote:
 Hello everyone,

 I am happy to announce that in the next DMD release you will be 
 able to more freely enjoy your metaprograming experience now 
 that a long-standing limitation has been lifted.

 You can now instantiate local and member templates with local 
 symbols.

 Example:
 ---
 struct S
 {
     private int _m;
     void exec(alias fun)()
     {
         fun(_m);
     }
 }

 unittest
 {
     int localVar;

     void set(int i)
     {
         localVar = i;
     }

     auto obj = S(10);
     obj.exec!set();   // no error or warning

     assert(localVar == 10);
 }
 ---

 I hope you enjoy!
Thanks a lot. It is really refreshing to know this has been fixed.
Apr 26