Inline imports redivivus

Ali Çehreli acehreli at yahoo.com
Tue Mar 8 23:25:49 UTC 2022


On 3/8/22 14:28, Paul Backus wrote:

 > There's always strings:

And they are the eyesore! :)

 >      bitfields!("int x : 8",
 >                 "int y : 8");

But you give me the idea that if we allow "this template parameter is a 
string" and don't require strings at the use site, then it would work 
for the above case as well. Basically, the string is contains my domain 
specific language as you show and I can do anything I want with it.

Brain storming with a 'new string' syntax:

template bitfields(new string args...) {
   // ...
}

   bitfields!(int x : 8,
              int y : 8);

And the template instance sees two strings: "int x : 8" and "int y : 8" 
and has fun parsing them at compile time. Again, this feels natural to 
me because it is related to opDispatch.

Of course there are syntax issues: Nothing that takes part in a 
parameter list can be a part of the string. I think they are just ',' to 
allow multiple 'new string' parameters and ')' to allow closing the 
parameter list. When needed, they could be written with backslashes as 
\, and \).

Wow! I've just written a DIP! :P

Ali



More information about the Digitalmars-d mailing list