Here Doc |
|
|
Will be nice if we can use the heredoc capability, well it is already there but with a fixed delimiter "[[" and "]]" and the ability to make variables substitution inside strings like perl, tcl, ruby. |
It could be nice if we could use heredocs[1] in Lua. Well, it is already there but with a fixed delimiter "[[" and "]]"[2]. |
|
This change would make Lua harder to parse (for external parsers, too, which interest me. I think [[ ]] strings are just fine, personally. Remember that Lua does count [[ and ]] inside the strings, although as someone pointed out this fails in certain cases, like: |
This change would make Lua harder to parse (for external parsers, too, which interest me. I think [[ ]] strings are just fine, personally. Remember that Lua does count [[ and ]] inside the strings, although as someone pointed out this fails in certain cases, like: |
Variable substitution inside strings is a nightmare in the general case (and creates other parsing problems, as well as some ambiguity about the use of local variables). The syntax:a = 'The value of x is"' ..x.. '".\n' is really not that awkward, although I admit it's not quite so compact as Perl. But here's something which is quite compact: StringInterpolation |
|
I would encourage people to try to figure out how to use the power and simplicity of Lua rather than trying to make it into some other language. --RiciLake |
Solution: a = [=[ [a, [b, c]] ]=] |
|
=== See Also === |
|
I would encourage people to try to figure out how to use the power and simplicity of Lua rather than trying to make it into some other language. --RiciLake |
|
* StringInterpolation |
[[" and "]]"[2].
[[ ]] strings are just fine, personally. Remember that Lua does count [[ and ]] inside the strings, although as someone pointed out this fails in certain cases, like:
a = [[ [a, [b, c]] ]]
a = [=[ [a, [b, c]] ]=]