proposal: a new string litteral to embed variables in a string

Timothee Cour thelastmammoth at gmail.com
Tue Nov 5 18:38:43 PST 2013


On Tue, Nov 5, 2013 at 5:42 PM, Manu <turkeyman at gmail.com> wrote:

> While thinking on a new string literal that may support DSL's, the syntax
> should optionally receive a language specification on opening.
> The thing that sucks most about DSL's is that the IDE can't syntax hilight
> them, but if it was provided what language the string was, then a smart IDE
> could apply syntax hilighting for that language within the scring scope.
> Eg, this sort of thing is supported in html, which is usually hilighted
> correctly by IDE's:
>   <script type="text/javascript"> or <script language="javascript">
>
> And exists in many other places too.
>

I agree. For that suggest the following syntax (independent of this
proposal):

That is, support UDA for expressions.

----
void main(){
  import std.conv:text;

  int var=12;

  @("syntax=python")
  r{
    def fun:
      print(@var) #will expand to tuple element 12
      print(@(var.to!string)) #will expand to tuple element "12"

    }
   .text
   .run_python;

  void run_python(string a){
    import std.system;
    system("python -c "~a.escapeShellFileName);
  }
}
----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131105/5d776092/attachment.html>


More information about the Digitalmars-d mailing list