digitalmars.D - DMD 0.148 - regular expressions
- Walter Bright (5/5) Feb 25 2006 The match expressions are gone. Based on the feedback, people didn't wan...
- Thomas Kuehne (16/17) Feb 26 2006 -----BEGIN PGP SIGNED MESSAGE-----
- Unknown W. Brackets (2/16) Feb 26 2006
- James Dunne (7/29) Feb 26 2006 OMG, teh ambiguity! =P
- Lars Ivar Igesund (3/8) Feb 26 2006 I liked the idea (match expressions), just not the operator, and I thoug...
- Ivan Senji (2/14) Feb 26 2006 Me too (except I even liked the operator) :)
- Tom (13/27) Feb 26 2006 There was a common opinion but on the opposed. I felt the same as Walter...
- Lars Ivar Igesund (5/40) Feb 26 2006 I think the "common opinion" was too coloured by the fact that we didn't
- Kyle Furlong (2/40) Feb 26 2006 IMHO, match expressions are not a natural part of a language that claims...
- Tom (3/43) Feb 26 2006 Maybe (don't think so) but we'll have to see it to believe it. ;-)
- Dave (8/54) Feb 26 2006 IMHO, the vote would be about 70 - 30 for the built-in's, especially wit...
- Dave (15/23) Feb 26 2006 So did I (but the operators didn't bother me). I was surprised to see th...
- Trevor Parscal (10/36) Feb 26 2006 I think the addition and than removal was pretty odd.. I was just about ...
- James Dunne (7/57) Feb 26 2006 Why is this move (taking out the built-in behavior) so seemingly
- Lars Ivar Igesund (6/62) Feb 26 2006 You are of course correct in this, but it in my (quite so erratic at tim...
- Walter Bright (10/16) Feb 26 2006 It's still there in the form:
- Walter Bright (7/15) Feb 26 2006 I wouldn't have removed it, but adding the declarations to the if statem...
- Walter Bright (7/9) Feb 26 2006 if ("regex" ~~ "string")
- Johan Granberg (6/19) Feb 26 2006 Why not do like this instead?
- Walter Bright (4/9) Feb 26 2006 Because it doesn't offer enough utility over the function version to jus...
- Derek Parnell (14/24) Feb 26 2006 I don't think that is quite correct. This program failed to compile ....
- Tom (5/30) Feb 26 2006 This was pretty obvious IMO, don't you think so? :) I mean, if the featu...
- Derek Parnell (12/51) Feb 26 2006 Of course it was obvious; that was my point.
- Tom (5/54) Feb 26 2006 Ok, I forgive you :) :P
- Walter Bright (3/4) Feb 26 2006 That's right.
- Dave (11/39) Feb 26 2006 Maybe a good compromise would be to use a built-in "proxy" for search() ...
- Lionello Lunesu (7/12) Feb 27 2006 Too bad you didn't create a separate thread for the new if statement. Wh...
- Lionello Lunesu (1/3) Feb 27 2006 Nevermind. I've found the thread already...
- Dave (12/14) Mar 02 2006 I haven't seen this brought up yet, so if it has my apologies.
- Chris Sauls (6/28) Mar 02 2006 I hadn't even thought of that yet... and I love it! A server project o...
- Walter Bright (5/9) Mar 03 2006 It'll stay in, but it'll be in the form:
- Ivan Senji (8/23) Mar 04 2006 Will this work:
- Walter Bright (8/12) Mar 06 2006 No, it won't work. Embedding declarations inside expressions leads to al...
- Ivan Senji (2/22) Mar 06 2006
- Brad Roberts (20/36) Mar 06 2006 Easy enough to define the behavior. I'm not sure what an
- Sean Kelly (8/12) Mar 06 2006 I had the same thought. But how much value is there in offering this
- Walter Bright (24/25) Mar 08 2006 I know. But if there isn't an obvious and intuitive behavior to define, ...
The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).
Feb 25 2006
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Walter Bright schrieb am 2006-02-26:Instead, foreach statements now allow implicit typing of the key/value declarations[snip] The only missing implicit typing: <g> Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEAXyk3w+/yD4P9tIRAlmMAKDOAaV/R2cXBx8stfaO5Hw86tgPsQCgpAbu HeEgU5DtCYRndFs/FGVFgZw= =57jc -----END PGP SIGNATURE-----
Feb 26 2006
That looks absolutely amazing. I want. -[Unknown]Walter Bright schrieb am 2006-02-26:Instead, foreach statements now allow implicit typing of the key/value declarations[snip] The only missing implicit typing: <g> Thomas
Feb 26 2006
Unknown W. Brackets wrote:That looks absolutely amazing. I want. -[Unknown]OMG, teh ambiguity! =P Anyway, you really can't do this at the moment? Oh well, probably because auto parameters don't exist yet (AFAIK). -- Regards, James DunneWalter Bright schrieb am 2006-02-26:Instead, foreach statements now allow implicit typing of the key/value declarations[snip] The only missing implicit typing: <g> Thomas
Feb 26 2006
Walter Bright wrote:The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
Lars Ivar Igesund wrote:Walter Bright wrote:Me too (except I even liked the operator) :)The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
In article <dts7qi$18b0$1 digitaldaemon.com>, Ivan Senji says...Lars Ivar Igesund wrote:There was a common opinion but on the opposed. I felt the same as Walter about match expressions in the NG. My own thought about match expressions is that they introduce TOO MUCH lib functionality (common only for certain types of apps), making D *very* overloaded (think about future writers of the compiler). The most of the people felt that introducing match expressions really introduces NO NEW functionality. Rather it just saves you the time of writing "import std.regexp;" (i guess). And also they introduced more complexity than needed and new bugs to fix. Match expressions was a luxury that D couldn't afford as D has many other *really-prior-and-crucial* things to work out if it want's to become 1.0. JMHO Tom;Walter Bright wrote:Me too (except I even liked the operator) :)The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
Tom wrote:In article <dts7qi$18b0$1 digitaldaemon.com>, Ivan Senji says...I think the "common opinion" was too coloured by the fact that we didn't really expect it to go away (but maybe change), thus many of those having positive feelings toward the match expressions didn't voice their opinion at all (at least I didn't). But I guess a vote would give a 50/50 result :)Lars Ivar Igesund wrote:There was a common opinion but on the opposed. I felt the same as Walter about match expressions in the NG. My own thought about match expressions is that they introduce TOO MUCH lib functionality (common only for certain types of apps), making D *very* overloaded (think about future writers of the compiler). The most of the people felt that introducing match expressions really introduces NO NEW functionality. Rather it just saves you the time of writing "import std.regexp;" (i guess). And also they introduced more complexity than needed and new bugs to fix. Match expressions was a luxury that D couldn't afford as D has many other *really-prior-and-crucial* things to work out if it want's to become 1.0. JMHO Tom;Walter Bright wrote:Me too (except I even liked the operator) :)The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
Lars Ivar Igesund wrote:Tom wrote:IMHO, match expressions are not a natural part of a language that claims to be for systems programming.In article <dts7qi$18b0$1 digitaldaemon.com>, Ivan Senji says...I think the "common opinion" was too coloured by the fact that we didn't really expect it to go away (but maybe change), thus many of those having positive feelings toward the match expressions didn't voice their opinion at all (at least I didn't). But I guess a vote would give a 50/50 result :)Lars Ivar Igesund wrote:There was a common opinion but on the opposed. I felt the same as Walter about match expressions in the NG. My own thought about match expressions is that they introduce TOO MUCH lib functionality (common only for certain types of apps), making D *very* overloaded (think about future writers of the compiler). The most of the people felt that introducing match expressions really introduces NO NEW functionality. Rather it just saves you the time of writing "import std.regexp;" (i guess). And also they introduced more complexity than needed and new bugs to fix. Match expressions was a luxury that D couldn't afford as D has many other *really-prior-and-crucial* things to work out if it want's to become 1.0. JMHO Tom;Walter Bright wrote:Me too (except I even liked the operator) :)The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
In article <dtse93$1fou$1 digitaldaemon.com>, Lars Ivar Igesund says...Tom wrote:Maybe (don't think so) but we'll have to see it to believe it. ;-) Tom;In article <dts7qi$18b0$1 digitaldaemon.com>, Ivan Senji says...I think the "common opinion" was too coloured by the fact that we didn't really expect it to go away (but maybe change), thus many of those having positive feelings toward the match expressions didn't voice their opinion at all (at least I didn't). But I guess a vote would give a 50/50 result :)Lars Ivar Igesund wrote:There was a common opinion but on the opposed. I felt the same as Walter about match expressions in the NG. My own thought about match expressions is that they introduce TOO MUCH lib functionality (common only for certain types of apps), making D *very* overloaded (think about future writers of the compiler). The most of the people felt that introducing match expressions really introduces NO NEW functionality. Rather it just saves you the time of writing "import std.regexp;" (i guess). And also they introduced more complexity than needed and new bugs to fix. Match expressions was a luxury that D couldn't afford as D has many other *really-prior-and-crucial* things to work out if it want's to become 1.0. JMHO Tom;Walter Bright wrote:Me too (except I even liked the operator) :)The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
In article <dtsge2$1i5t$1 digitaldaemon.com>, Tom says...In article <dtse93$1fou$1 digitaldaemon.com>, Lars Ivar Igesund says...IMHO, the vote would be about 70 - 30 for the built-in's, especially with the addition of 'if statement result declarations' that would get rid of the implicit variables. Since AFAIK they don't complicate the compiler that much, they don't have any overhead if they aren't used and don't prevent the direct use of a regex library, I don't see any downside of making them built-in. - DaveTom wrote:Maybe (don't think so) but we'll have to see it to believe it. ;-) Tom;In article <dts7qi$18b0$1 digitaldaemon.com>, Ivan Senji says...I think the "common opinion" was too coloured by the fact that we didn't really expect it to go away (but maybe change), thus many of those having positive feelings toward the match expressions didn't voice their opinion at all (at least I didn't). But I guess a vote would give a 50/50 result :)Lars Ivar Igesund wrote:There was a common opinion but on the opposed. I felt the same as Walter about match expressions in the NG. My own thought about match expressions is that they introduce TOO MUCH lib functionality (common only for certain types of apps), making D *very* overloaded (think about future writers of the compiler). The most of the people felt that introducing match expressions really introduces NO NEW functionality. Rather it just saves you the time of writing "import std.regexp;" (i guess). And also they introduced more complexity than needed and new bugs to fix. Match expressions was a luxury that D couldn't afford as D has many other *really-prior-and-crucial* things to work out if it want's to become 1.0. JMHO Tom;Walter Bright wrote:Me too (except I even liked the operator) :)The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
In article <dts47r$14c0$1 digitaldaemon.com>, Lars Ivar Igesund says...Walter Bright wrote:So did I (but the operators didn't bother me). I was surprised to see the 'built-in' behaviour removed. From my understanding, it wasn't terribly complicated to implement and there wasn't any overhead unless it was used. There really wasn't any 'perl'ish notation' to speak of, and the recent addition of if statement result variables would have taken care of the implicitly defined variable issue. I think it was a mistake to remove the built-in's. Now I bet they're gone for good. Arrrgh. I think D would better appeal to a large segment of developers (using scripting languages like Perl) with the built-in regex match functionality. IIRC, most of the posts liked the built-in idea but took issue with a few of the details. We've gone from talk about how the compiler can optimize matching behaviour to removing the built-in's entirely. I don't get it.. - DaveThe match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
In article <dtsjs6$1lp0$1 digitaldaemon.com>, Dave says...In article <dts47r$14c0$1 digitaldaemon.com>, Lars Ivar Igesund says...I think the addition and than removal was pretty odd.. I was just about to rewrite some code using the match operator - but I am glad I diddn't. But you know - as much as we all demand features and get mad when they aren't included, it was nice to see a feature get included. But now it gets taken away so quickly, I don't know what will be taken out next.. :) Please don't remove dynamic arrays walter! Just kidding - we all love you! Thanks, Trevor ParscalWalter Bright wrote:So did I (but the operators didn't bother me). I was surprised to see the 'built-in' behaviour removed. From my understanding, it wasn't terribly complicated to implement and there wasn't any overhead unless it was used. There really wasn't any 'perl'ish notation' to speak of, and the recent addition of if statement result variables would have taken care of the implicitly defined variable issue. I think it was a mistake to remove the built-in's. Now I bet they're gone for good. Arrrgh. I think D would better appeal to a large segment of developers (using scripting languages like Perl) with the built-in regex match functionality. IIRC, most of the posts liked the built-in idea but took issue with a few of the details. We've gone from talk about how the compiler can optimize matching behaviour to removing the built-in's entirely. I don't get it.. - DaveThe match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
Trevor Parscal wrote:In article <dtsjs6$1lp0$1 digitaldaemon.com>, Dave says...Why is this move (taking out the built-in behavior) so seemingly unexpected to everyone? Walter outright said "Don't write production code with this feature." -- Regards, James DunneIn article <dts47r$14c0$1 digitaldaemon.com>, Lars Ivar Igesund says...I think the addition and than removal was pretty odd.. I was just about to rewrite some code using the match operator - but I am glad I diddn't. But you know - as much as we all demand features and get mad when they aren't included, it was nice to see a feature get included. But now it gets taken away so quickly, I don't know what will be taken out next.. :) Please don't remove dynamic arrays walter! Just kidding - we all love you! Thanks, Trevor ParscalWalter Bright wrote:So did I (but the operators didn't bother me). I was surprised to see the 'built-in' behaviour removed. From my understanding, it wasn't terribly complicated to implement and there wasn't any overhead unless it was used. There really wasn't any 'perl'ish notation' to speak of, and the recent addition of if statement result variables would have taken care of the implicitly defined variable issue. I think it was a mistake to remove the built-in's. Now I bet they're gone for good. Arrrgh. I think D would better appeal to a large segment of developers (using scripting languages like Perl) with the built-in regex match functionality. IIRC, most of the posts liked the built-in idea but took issue with a few of the details. We've gone from talk about how the compiler can optimize matching behaviour to removing the built-in's entirely. I don't get it.. - DaveThe match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
James Dunne wrote:Trevor Parscal wrote:You are of course correct in this, but it in my (quite so erratic at times) mind, this meant that the syntax probably would be changed, not removed altoghether. Also, I don't really think the D as Script feature makes much sense without some additional regexy sugar, even if it is still quite usable of course.In article <dtsjs6$1lp0$1 digitaldaemon.com>, Dave says...Why is this move (taking out the built-in behavior) so seemingly unexpected to everyone? Walter outright said "Don't write production code with this feature."In article <dts47r$14c0$1 digitaldaemon.com>, Lars Ivar Igesund says...I think the addition and than removal was pretty odd.. I was just about to rewrite some code using the match operator - but I am glad I diddn't. But you know - as much as we all demand features and get mad when they aren't included, it was nice to see a feature get included. But now it gets taken away so quickly, I don't know what will be taken out next.. :) Please don't remove dynamic arrays walter! Just kidding - we all love you! Thanks, Trevor ParscalWalter Bright wrote:So did I (but the operators didn't bother me). I was surprised to see the 'built-in' behaviour removed. From my understanding, it wasn't terribly complicated to implement and there wasn't any overhead unless it was used. There really wasn't any 'perl'ish notation' to speak of, and the recent addition of if statement result variables would have taken care of the implicitly defined variable issue. I think it was a mistake to remove the built-in's. Now I bet they're gone for good. Arrrgh. I think D would better appeal to a large segment of developers (using scripting languages like Perl) with the built-in regex match functionality. IIRC, most of the posts liked the built-in idea but took issue with a few of the details. We've gone from talk about how the compiler can optimize matching behaviour to removing the built-in's entirely. I don't get it.. - DaveThe match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...
Feb 26 2006
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dtso8j$1r01$1 digitaldaemon.com...You are of course correct in this, but it in my (quite so erratic at times) mind, this meant that the syntax probably would be changed, not removed altoghether. Also, I don't really think the D as Script feature makes much sense without some additional regexy sugar, even if it is still quite usable of course.It's still there in the form: if (m; search("string", "pattern")) ... do something with m.match(0) ... as opposed to: if ("pattern" ~~ "search") ... do something with _match.match(0) ... There isn't much sugar to the latter over the former, and it has the disadvantage of implicit declarations, which in general are a bad idea.
Feb 26 2006
"Trevor Parscal" <Trevor_member pathlink.com> wrote in message news:dtsl91$1ncs$1 digitaldaemon.com...I think the addition and than removal was pretty odd.. I was just about to rewrite some code using the match operator - but I am glad I diddn't. But you know - as much as we all demand features and get mad when they aren't included, it was nice to see a feature get included. But now it gets taken away so quickly, I don't know what will be taken out next.. :)I wouldn't have removed it, but adding the declarations to the if statement, and the implicit typing to the foreach, made the match expression's incremental convenience pretty minor. Lest D become a bag of cruft, new operators need to offer a *big* improvement in convenience.Please don't remove dynamic arrays walter!Fat chance of that!
Feb 26 2006
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
Walter Bright wrote:"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...Why not do like this instead? if (m;"regex" ~~ "string") m. ... That would get rid of the implicit declaration of _match and just like usual with statements the result of ~~ could bee ignored.I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
"Johan Granberg" <lijat.meREM OVEgmail.com> wrote in message news:dtsu0h$21ct$1 digitaldaemon.com...Why not do like this instead? if (m;"regex" ~~ "string") m. ... That would get rid of the implicit declaration of _match and just like usual with statements the result of ~~ could bee ignored.Because it doesn't offer enough utility over the function version to justify it.
Feb 26 2006
On Mon, 27 Feb 2006 04:58:21 +1100, Walter Bright <newshound digitalmars.com> wrote:"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...I don't think that is quite correct. This program failed to compile .... void main() { if (m; search("string", "regex")) {} } I got the messages ... test2.d(3): undefined identifier search test2.d(3): function expected before (), not search of type int It turns out that "import std.regexp;" is now required. -- Derek Parnell Melbourne, AustraliaI liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
In article <op.s5lhaxyb6b8z09 ginger.vic.bigpond.net.au>, Derek Parnell says...On Mon, 27 Feb 2006 04:58:21 +1100, Walter Bright <newshound digitalmars.com> wrote:This was pretty obvious IMO, don't you think so? :) I mean, if the feature was removed, of course, you would require 'std.regexp' imported again. I think Walter omitted it because of that. Tom;"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...I don't think that is quite correct. This program failed to compile .... void main() { if (m; search("string", "regex")) {} } I got the messages ... test2.d(3): undefined identifier search test2.d(3): function expected before (), not search of type int It turns out that "import std.regexp;" is now required.I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
On Mon, 27 Feb 2006 06:46:41 +1100, Tom <Tom_member pathlink.com> wrote:In article <op.s5lhaxyb6b8z09 ginger.vic.bigpond.net.au>, Derek Parnell says...Of course it was obvious; that was my point. Walter had written that "if ("regex" ~~ "string")" was functionally equivalent to "if (m; search("string", "regex"))" and while that is true, it gives the impression that this was the *only* change to the new D. I just wanted to point out that the implicit importing of std.regexp was also removed. -- Derek Parnell Melbourne, AustraliaOn Mon, 27 Feb 2006 04:58:21 +1100, Walter Bright <newshound digitalmars.com> wrote:This was pretty obvious IMO, don't you think so? :) I mean, if the feature was removed, of course, you would require 'std.regexp' imported again. I think Walter omitted it because of that."Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...I don't think that is quite correct. This program failed to compile .... void main() { if (m; search("string", "regex")) {} } I got the messages ... test2.d(3): undefined identifier search test2.d(3): function expected before (), not search of type int It turns out that "import std.regexp;" is now required.I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
In article <op.s5lmdqep6b8z09 ginger.vic.bigpond.net.au>, Derek Parnell says...On Mon, 27 Feb 2006 06:46:41 +1100, Tom <Tom_member pathlink.com> wrote:Ok, I forgive you :) :P Now seriously, I see your point. Regards, Tom;In article <op.s5lhaxyb6b8z09 ginger.vic.bigpond.net.au>, Derek Parnell says...Of course it was obvious; that was my point. Walter had written that "if ("regex" ~~ "string")" was functionally equivalent to "if (m; search("string", "regex"))" and while that is true, it gives the impression that this was the *only* change to the new D. I just wanted to point out that the implicit importing of std.regexp was also removed.On Mon, 27 Feb 2006 04:58:21 +1100, Walter Bright <newshound digitalmars.com> wrote:This was pretty obvious IMO, don't you think so? :) I mean, if the feature was removed, of course, you would require 'std.regexp' imported again. I think Walter omitted it because of that."Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...I don't think that is quite correct. This program failed to compile .... void main() { if (m; search("string", "regex")) {} } I got the messages ... test2.d(3): undefined identifier search test2.d(3): function expected before (), not search of type int It turns out that "import std.regexp;" is now required.I liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
"Derek Parnell" <derek psych.ward> wrote in message news:op.s5lhaxyb6b8z09 ginger.vic.bigpond.net.au...It turns out that "import std.regexp;" is now required.That's right.
Feb 26 2006
In article <op.s5lhaxyb6b8z09 ginger.vic.bigpond.net.au>, Derek Parnell says...On Mon, 27 Feb 2006 04:58:21 +1100, Walter Bright <newshound digitalmars.com> wrote:Maybe a good compromise would be to use a built-in "proxy" for search() and RegExp (along the same lines as '~~' was originally implemented)? Then there would be no "perl'ish" syntax, no added operators, no overhead and the same convenience to doing regex matching. One problem I see with the new v0.148 regex stuff is that different search functions (and syntax for them) are used for if() and foreach(), and they aren't interchangable. That's going to be confusing for newbies and feels kludgy to me - can't the two functions be combined somehow? - Dave"Lars Ivar Igesund" <larsivar igesund.net> wrote in message news:dts47r$14c0$1 digitaldaemon.com...I don't think that is quite correct. This program failed to compile .... void main() { if (m; search("string", "regex")) {} } I got the messages ... test2.d(3): undefined identifier search test2.d(3): function expected before (), not search of type int It turns out that "import std.regexp;" is now required. -- Derek Parnell Melbourne, AustraliaI liked the idea (match expressions), just not the operator, and I thought that was a common opinion...if ("regex" ~~ "string") _match. ... The equivalent functionality can now be done with: if (m; search("string", "regex")) m. ...
Feb 26 2006
"Walter Bright" <newshound digitalmars.com> wrote in message news:dtr2ff$2vqr$3 digitaldaemon.com...The match expressions are gone. Based on the feedback, people didn't want D to adopt perl'ish notation or implicitly defined variables. Instead, foreach statements now allow implicit typing of the key/value declarations, and the if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).Too bad you didn't create a separate thread for the new if statement. What was wrong with the C++ construction: if (int a = getSome()) {...} ? L.
Feb 27 2006
Too bad you didn't create a separate thread for the new if statement. What was wrong with the C++ construction:Nevermind. I've found the thread already...
Feb 27 2006
In article <dtr2ff$2vqr$3 digitaldaemon.com>, Walter Bright says...if statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I haven't seen this brought up yet, so if it has my apologies. The if(valptr; (key in AA)) syntax also nicely improves on how 'in' is used to avoid double lookups IMO. Still uses a pointer, but it is alot better. old way: int* p = (key in AA); if(p) (*p)++; else AA[key] = 1; new: if(p; key in AA) (*p)++; else AA[key] = 1; - Dave
Mar 02 2006
Dave wrote:In article <dtr2ff$2vqr$3 digitaldaemon.com>, Walter Bright says...I hadn't even thought of that yet... and I love it! A server project of mine uses the 'in' operator quite a bit, and I've always been annoyed with predeclaring variables and whatnot. Now I won't have that issue, so long as Walter does the Right Thing (TM) and leaves this in. -- Chris Nicholson-Saulsif statement now can declare a variable for the result (an adaptation of Ben Hinkle's idea).I haven't seen this brought up yet, so if it has my apologies. The if(valptr; (key in AA)) syntax also nicely improves on how 'in' is used to avoid double lookups IMO. Still uses a pointer, but it is alot better. old way: int* p = (key in AA); if(p) (*p)++; else AA[key] = 1; new: if(p; key in AA) (*p)++; else AA[key] = 1; - Dave
Mar 02 2006
"Chris Sauls" <ibisbasenji gmail.com> wrote in message news:du8kgk$tem$1 digitaldaemon.com...I hadn't even thought of that yet... and I love it! A server project of mine uses the 'in' operator quite a bit, and I've always been annoyed with predeclaring variables and whatnot. Now I won't have that issue, so long as Walter does the Right Thing (TM) and leaves this in.It'll stay in, but it'll be in the form: if (auto p = key in AA) as just about everyone seemed to prefer that syntax.
Mar 03 2006
Walter Bright wrote:"Chris Sauls" <ibisbasenji gmail.com> wrote in message news:du8kgk$tem$1 digitaldaemon.com...Will this work: if( auto a = something() && auto b = something()) a more general solution of declaring/initializing variables by parts of expressions? (auto a1 = x*y-z) * (1 - (auto a2 = sin(x+y)))? That would be a nice feature, but maybe too complicated and not that much used?I hadn't even thought of that yet... and I love it! A server project of mine uses the 'in' operator quite a bit, and I've always been annoyed with predeclaring variables and whatnot. Now I won't have that issue, so long as Walter does the Right Thing (TM) and leaves this in.It'll stay in, but it'll be in the form: if (auto p = key in AA) as just about everyone seemed to prefer that syntax.
Mar 04 2006
"Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message news:dubrop$118j$1 digitaldaemon.com...Will this work: if( auto a = something() && auto b = something()) a more general solution of declaring/initializing variables by parts of expressions?No, it won't work. Embedding declarations inside expressions leads to all sorts of problems, not the least of which is what happens in this scenario: if (auto a = foo() || auto b = bar()) { a + b; // is b declared or not? }
Mar 06 2006
Walter Bright wrote:"Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message news:dubrop$118j$1 digitaldaemon.com...OK, I get it.Will this work: if( auto a = something() && auto b = something()) a more general solution of declaring/initializing variables by parts of expressions?No, it won't work. Embedding declarations inside expressions leads to all sorts of problems, not the least of which is what happens in this scenario:if (auto a = foo() || auto b = bar()) { a + b; // is b declared or not? }
Mar 06 2006
On Mon, 6 Mar 2006, Walter Bright wrote:"Ivan Senji" <ivan.senji_REMOVE_ _THIS__gmail.com> wrote in message news:dubrop$118j$1 digitaldaemon.com...Easy enough to define the behavior. I'm not sure what an appropriate term is for variables declared like this, so insert something appropriate below. Something like this would work reasonably well, probably: For all variables declared in an if expression, they will be default initialized if their initializing expression is not executed due to short circuit evaluation. So.. if (auto /* int */ res1 = someIntegerExpression() || auto /* int */ res2 = someOtherIntegerExpression()) { return res1 + res2; } The results of that become well defined. What would be potentially problematic is if return types are ever added to function overloading / resolution. But I won't get into my opinions on that or on implicit typing as it's ornthogonal to this topic. Later, BradWill this work: if( auto a = something() && auto b = something()) a more general solution of declaring/initializing variables by parts of expressions?No, it won't work. Embedding declarations inside expressions leads to all sorts of problems, not the least of which is what happens in this scenario: if (auto a = foo() || auto b = bar()) { a + b; // is b declared or not? }
Mar 06 2006
Brad Roberts wrote:For all variables declared in an if expression, they will be default initialized if their initializing expression is not executed due to short circuit evaluation.I had the same thought. But how much value is there in offering this feature? Since D defaults to trap values when possible, the user should typically check all values that may have been default initialized before using them, and this seems to reduce the utility of this syntax. Though I suppose this doesn't change the fact that there is a simple, valid solution to the problem, which is the point you were trying to make. Sean
Mar 06 2006
"Brad Roberts" <braddr puremagic.com> wrote in message news:Pine.LNX.4.64.0603061143490.30259 bellevue.puremagic.com...Easy enough to define the behavior.I know. But if there isn't an obvious and intuitive behavior to define, then one is picking something arbitrary. For example, the classic conundrum is: "12" + 6 Does that evaluate to "126" or 18? One can easilly define the behavior, but which one, and what will programmers expect it to be? With that expression, there really are only wrong answers, and so the only solution is to make it illegal. For: if (auto a = foo() || auto b = bar()) { a + b; // is b declared or not? } one could as sensibly define that b is only valid in the conditional subexpression in which it appears, as in: if (auto a = foo() || (auto b = bar(), b + 1)) // ok, b valid in the b+1 expression { a + b; // error, b undefined here } Faced with two equally valid but incompatible definitions, I think the best course of action is to make it illegal, especially since there doesn't seem to be much utility in such a feature anyway.
Mar 08 2006