Understanding regexes (Was: Re: DMD 0.147 release)
Stewart Gordon
smjg_1998 at yahoo.com
Tue Feb 21 03:12:28 PST 2006
Georg Wrede wrote:
> Walter Bright wrote:
>> "Wang Zhen" <nehzgnaw at gmail.com> wrote in message
>> news:dt49iv$2hm5$1 at digitaldaemon.com...
>>
>>> Although syntactically correct, MatchExpression in
>>> StaticIfCondition or StaticAssert do not compile. For example:
>>>
>>> void main(){static if(!("" ~~ "")){}static assert("" ~~ "");}
>>>
>>> Is this intended or an unimplemented feature?
>>
>> The problem is that getting it to work requires the compiler itself
>> to understand regular expressions. Currently, it does not.
>
> Intriguing. I'd sure love to hear more about this.
>
> I take it understanding regular expressions is much more than just
> compiling them? (Like what the runtime does, or Perl, etc.?)
A problem is that there are a number of dialects of regexp. The spec
doesn't seem to indicate which dialect is being used.
Among the differences between them is whether subexpressions are
parenthesised by \(...\) or simply (...). Another issue is whether we
expect implementations to support the Unicode extensions to regexps
described here
http://www.textpad.info/forum/viewtopic.php?t=4778
No doubt there are other differences....
Whichever we choose, the behaviour of using std.regexp directly, ~~
evaluated at runtime and ~~ evaluated at compiletime must be consistent.
But that isn't hard - the compiler would just call the same code that
std.regexp uses.
Stewart.
--
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS-
PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y
------END GEEK CODE BLOCK------
My e-mail is valid but not my primary mailbox. Please keep replies on
the 'group where everyone may benefit.
More information about the Digitalmars-d-announce
mailing list