[Top][All Lists]

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

Re: Raw strings (experimental patches inside)

From: Dmitri Paduchikh
Subject: Re: Raw strings (experimental patches inside)
Date: Sat, 11 Aug 2012 17:05:53 +0600
User-agent: Gnus/5.13 (Gnus v5.13)

Stefan Monnier:

>>> And here we're back at regexps.  I already agreed that they're
>>> convenient for regexps, but pointed out that a better solution would be
>>> to fix the regexp syntax so it doesn't backslash-escape every
>>> special character.
>> Yeah, I know -- I pointed that out too.  That's still not a substitute
>> for raw strings in code.

SM> Why not?

>> You still need to *double*-backslash-escape, backslash-escaping is
>> insufficient.

SM> If the special chars don't need to be backslash escaped, then you don't
SM> need to double escape either, obviously.

I like the Lua way of solving this problem. They use different
characters for string and regexp escaping (\ and % correspondingly).
Choosing the same character for both purposes really creates a huge
opportunity for confusion, IMO.

$ lua
Lua 5.2.1  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> =string.find('-xyz-', '(%w+)')
2       4       xyz

But they also do not escape parentheses and have raw strings in the form
of `[[...]]`.

With best regards,
Dmitri Paduchikh

reply via email to

[Prev in Thread] Current Thread [Next in Thread]