emacs-devel
[Top][All Lists]
Advanced

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

Re: Unquoted special characters in regexps


From: martin rudalics
Subject: Re: Unquoted special characters in regexps
Date: Sun, 26 Feb 2006 18:10:10 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

>>That of closing a character alternative.  When you write
>>
>>(defvar foo "]")
>>(defvar bar "\\]")
>>
>>you can't interchangeably use `foo' and `bar' in an arbitrary regular
>>expression.  Some people call this "referential transparency".
>
>
> Of course you can't, since the meaning of '\' is context dependent.

When you say that outside a character alternative `]' and `\\]' have the
same meaning you abandon the principle of referential transparency.

>>Anyway, the first `]' has a special meaning but it's not "inside" the
>>character alternative.
>
>
> It is part of it, just like the leading '['.

As a consequence, in your model "[" is a valid regexp too.

>>It does have a special meaning because `]' is special _outside_
>>character alternatives.
>
>
> This is wrong.  Outside of a character set ']' has no special meaning
> whatsoever, independent of the context.

On a similar footing you can say that `*' has no special meaning unless
it's preceded by a character.  Hence "*foo" is valid too in your model.

>>According to the Elisp manual all these exhibit "poor practice" since
>>you didn't quote the second `]'s.
>
>
> It's a bug in the manual.

Please fix it.






reply via email to

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