Re: [Vala] interaction of parentheses and string template interpolation via the @ sign



OK, thanks for the explanation.

dan

On Sat, Dec 26, 2015 at 1:29 AM, Luca Bruno <lethalman88 gmail com> wrote:
I believe this is an issue with the lexer. Template strings are parsed at
syntax level, not parser level, hence it may not support nested parenthesis.

On Fri, Dec 25, 2015 at 8:17 PM, Dan Hitt <dan hitt gmail com> wrote:

If you do string interpolation via
    string s = @"some text $some_variable";
it produces a string like
    some text 5
if 5 were the value of some_variable.

But if you put parentheses in, this gets defeated:
    @("some text $some_variable")
just becomes
    some text $some_variable
with no interpolation of the value of some_variable into the string.

Is this intentional?

This is with vala 0.28.1 on ubuntu 15.10.

(And of course it is a very tiny issue, if it is an issue at all.  The
reason it
came up in the first place was i had something more complicated,
   @("a: $a\n" +
        "b: $b\n" +
        "c: $c\n")
and i was very surprised that this did not work.  It can be fixed by the
slightly lengthier form
    @"a: $a\n" +
    @"b: $b\n" +
    @"c: $c\n"
but i do wonder why grouping with parentheses has such a drastic effect.
And it also makes me wonder just what @ does and what it sees: clearly
it has greater visibility into its surroundings than just some function.)

Thanks in advance for any info.

dan
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list




--
NixOS Linux


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]