Error in template instantiation from D-Cookbook example

ShadoLight ettienne.gilbert at gmail.com
Fri Feb 9 22:33:48 UTC 2018


On Friday, 9 February 2018 at 21:39:22 UTC, Adam D. Ruppe wrote:
> On Friday, 9 February 2018 at 21:31:29 UTC, ShadoLight wrote:
>> [1] https://run.dlang.io/is/dyElXg
>
> There's missing quotes in there:
>
> Line 14:
> code ~= "push(call!"~piece~"(pop(), pop()));\n";
>
> Should be:
>
> code ~= "push(call!\""~piece~"\"(pop(), pop()));\n";
[snip]

On Friday, 9 February 2018 at 21:58:51 UTC, Meta wrote:
> On Friday, 9 February 2018 at 21:31:29 UTC, ShadoLight wrote:
[snip]
> The problem becomes apparent once you uncomment one of these 
> and paste the offending string ("5 5 + 3 - 2 * 1 + 3 /") in.
[snip]
> push(call!+(pop(), pop()));
[snip]
> So it takes a string as its sole template argument. The problem 
> is that the code in convertToD forgot to add the quotes around 
> the operators that are supposed to be passed as strings to call.
[snip]

Indeed, that makes sense! Thanks to you both!

Adam, you are right - it was indeed incorrectly mangled... it is 
shown as...
code ~= "push(call!'"~piece~"'(pop(), pop()));\n";

So the escaped quotes \" were mangled as '. I simply removed them 
since I assumed they were typos in the doc, similar to the other 
ones I had fixed. My bad.

Man, I cannot believe how quickly you guys answered. Thanks again!


More information about the Digitalmars-d-learn mailing list