proposal: a new string litteral to embed variables in a string
Chris Cain
clcain at uncg.edu
Tue Nov 5 19:43:55 PST 2013
On Wednesday, 6 November 2013 at 02:38:57 UTC, Timothee Cour
wrote:
> 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{
> ...snip...
> }
> }
> ----
I'd very nearly say that this could be a library function.
Imagine it like this:
---
syntax!"python"(r{
...
})
---
A bit more verbose than using a UDA but the return type could be
something like SyntaxType!"python" and you could make it so that
functions only take SyntaxType!"python" for some compile-time
checking using the type system. For instance, if your function
requires python code then you can specify it in the argument. I'd
also like it to be implicitly convertable to a generic SyntaxType
that accepts everything if you just don't care what kind of
syntax it is.
As long as it's part of the standard library, then IDEs could
also take advantage of it. Not saying that they shouldn't also
support UDAs, but just throwing that out there as another
alternative.
More information about the Digitalmars-d
mailing list