RE: [PHP-DEV] regex operators
| From: | Adam Maccabee Trachtenberg | Date: | Tue, 14 Oct 2003 18:36:20 +0000 |
| Subject: | RE: [PHP-DEV] regex operators | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-4844@lists.php.net to get a copy of this message | ||
On 14 Oct 2003, Robert Cummings wrote:
> Why would this make regular expressions more widespread? I would expect
> that regular expressions are used wherever necessary and otherwise not
> used, regardless of syntax. Or are you saying because regex matching is
> invoked via a function that you don't use regex? In such a case I'd have
> to ask what you use instead!?
Following that logic, why would anyone prefer one Turing-complete
language over another? They only differ in their syntax. :) Okay, this
is an extreme example.
However, I think it is safe to say that language syntax and grammar
cause users to exhibit a tendency to use one set of techniques in
comparison to another.
As a general rule, PHP's operators (i.e. funny looking punctuation)
are easily recognizable basics; its functions (i.e. letters with () at
the end) are ones that need more clarify of identification at the
expense of extra letters. (Not exactly, but I'm generalizing here.)
I guess the real questions here (to me) is are regular expressions a
common enough action and is "=~" a common enough symbol that it's
worth a decrease in clarity? I don't know. Regular expressions have
certainly shown their frequent usefulness. I've always hated =~ as a
symbol, but with Perl's popularity, it doesn't really makes sense to
choose anything else.
In the 70s, regular expressions were expensive, so languages like C
didn't include a regex operator. Why should we be bound by the
decisions of K&R and strongly typed languages? At some point,
languages moved away from the Lisp camp, where everything was a
word. Lisp is super verbose, but I don't see people advocating for a
return, even if we got rid of all the stupid (()())s.
As Dave said, we added === when no other language in the world has
that. Why would =~ be necessarily more confusing?
-adam
--
adam@trachtenberg.com