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

Jacob Carlborg doob at me.com
Thu Nov 7 02:27:27 PST 2013


On 2013-11-06 23:48, Timothee Cour wrote:

> As I mentioned in my OT, this is what I already have implemented ("I've
> actually already implemented this feature via a mixin, and find it
> extremely useful, but ... "); and I did take care of proper escaping,
> etc. I am using it extensively, however the requirement for using a
> mixin makes things uglier than they should:
>
> * cryptic ctfe error msgs upon wrong variable names
> * mixin can't be used in UFCS chains; additional () nesting
> to the point that I only use it in cases where the alternative is uglier.
> * potentially more strain on ctfe
> * mixins in general should be used sparingly
>
> Sure we can use existing mixins to fill this need, but to me this is
> exactly the same as the situation with lambda literal syntax:
>
> a=>a*2
> instead of
> (a){return a*2;}
>
> or lazy parameters:
> void fun(lazy string a)
> vs:
> void fun(string delegate() a)
>
> A little of syntax sugar can provide huge benifits.
> It's use case would apply to all assert error messages, DSLs etc.

I agree with you, but I rather have a more general solution. That is, 
AST macros.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list