[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [PATCH] Expressions/variables within strings (aka no more '..')
- From: Karel Tuma <ktuma@...>
- Date: Mon, 23 Oct 2006 12:55:42 +0200
hi,
On Mon, Oct 23, 2006 at 11:19:31AM +0200, Grellier, Thierry wrote:
> Actually I don't see much the benefit of \$ \ against ".. .." : that
> only saves 3 chars
${variable} saves only 3 chars too.
> , may be confusing with \n in some cases, and may
> break existing code. Well you will say that then don't use patch. And I
> agree !
> Simply I'm just putting warning before someone makes lobbying to include
> this in lua.
none of this syntactic bloat should be introduced into core lua.
however, i must disagree that it's likely to clash with existing code.
\ is special in many ways. the most important that it's an escape
character, "\$" is superfluous because it results just "$" without the
patch. terminating \ token is expected only if \$ is introduced.
your real world code would look something like:
macro = "del $dirname\\$filename.txt\ndel $dirname.back\\$filename.txt"
to have some real meaning - and of course works with the patch.
either way, if you've any idea how to get rid of terminating token
(detect end of parsed expression) i'm open to suggestions ;-)
> To give an in on how it may break existing code, I'll give an example. I
> already use $ combined with string.gsub to perform multiple replacements
> at once in macro generation, eventually with some formatting.
> Although I don't have code like this, I may have:
> function delfile(dirname, filename)
> macro = "del $dirname\$filename.txt\ndel
> $dirname.back\$filename.txt\n"
> generated = string.gsub(macro, "$dirname", string.upper(dirname))
> generated = string.gsub(generated, "$filename",
> string.upper(filename))
> os.execute(generated)
> end
>
>