if(;){} opinion
Stewart Gordon
smjg_1998 at yahoo.com
Mon Feb 27 06:08:04 PST 2006
Georg Wrede wrote:
> Better 'fess up front: the intent of this post is to once and for all
> murder, pulverize and extradite the new if construct.
>
> Consider:
>
> if (m; std.regexp.search("abcdef", "b(c)d"))
<snip>
> Now consider:
>
> if (Regexp m = std.regexp.search("abcdef", "b(c)d"))
> {
> writefln("[%s]", m.pre); // prints [a]
> writefln("[%s]", m.post); // prints [ef]
> writefln("[%s]", m.match(0)); // prints [bcd]
> writefln("[%s]", m.match(1)); // prints [c]
> writefln("[%s]", m.match(2)); // prints []
> }
>
> Flaunting this around (to both the original programmers, and also to
> virgin victims), gave the same, _immediate_ comment from everybody: "Ah,
> that's neat!"
It should be quite straightforward to support both syntaxes. People
could have the choice of declaration syntax to match for, or semicolon
syntax to match foreach.
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
mailing list