Here Doc

lua-users home
wiki

Difference (from prior major revision) (no other diffs)

Changed: 1c1
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].

Changed: 3c3
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:

Changed: 7,11c7
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

Added: 12a9
Solution: a = [=[ [a, [b, c]] ]=]

Added: 13a11
=== See Also ===

Changed: 15c13
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

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:

a = [[ [a, [b, c]] ]]

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


RecentChanges · preferences
edit · history
Last edited October 18, 2008 9:24 pm GMT (diff)