Peter Scott <Peter@PSDT.com> writes: > Every hypothetical case I've seen involving wildly heterogeneous > 'when' clauses in the same given block has been contrived > example-ware. I don't see those in real life often enough to justify > the burden that having ~~ in the language would exact in too many > other cases. Indeed. Case (switch, select, ...) statements have always been intended to serve two purposes: the programmer and the compiler. To the programmer it provides a quick and hopefully elegant way to test something against several constant values. Constant is important for the second purpose, since it can be compiled into a very efficient branch table. For its implementation in Perl5 I only see beneficial: for ( ... ) { # or given when ( 404 ) { ... } when ( 501, 503, 777 ) { ... } ... otherwise ... } and for ( ... ) { # or given when ( "head" ) { ... } when ( "p", "div", "article" ) { ... } ... otherwise ... } It would be very nice if it were possible to use use constant constants but much to my astonishment these constants do not seem to be sufficiently constant. I see no real benefits in adding given/when as mere syntactic sugar for chained if/then/else constructs. We already have enough of these. As for using smartmatch, see below. > I regret to say that I have come to think of it as the > too-smart-for-its-own-good-match operator. Precisely. Smartmatch was a good idea but unfortunately it turns out to be a big implementation/usage problem. Beyond repair, I'm afraid. -- JohanThread Previous | Thread Next