|
Re: WHEN and UNLESS, if you will (was: [ANN] Introducing Scala, step 1): msg#00489lang.scala
"Steven E. Harris" <seh@xxxxxxxxx> writes: > From the comments, > > ,---- > | note that 'if' returns a value > `---- > > Has there been any discussion about augmenting "if" with its friends > "when" and "unless"¹, as provided in Common Lisp? There, > > (when test-form consequent) > These only really seems to pay off if you have multiple statements in the consequent. In Lisp, it is nice to write things like: (when test statement1 statement2) If you wrote it with an if, it would be significantly longer: (if test (begin statement1 statement2)) Scala just writes {} instead of (begin ), so the saving is not worth it. Incidentally, there is something analogous in Scala: cases in a pattern match do not need to have braces around them multiple statements. case Foo => statement1 statement2 statement3 case Bar => statement4 statement5 -Lex |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Scala paper: Actors that Unify Threads and Events: 00489, Terrance Sullivan |
|---|---|
| Next by Date: | Re: two things about defs: 00489, Lex Spoon |
| Previous by Thread: | WHEN and UNLESS, if you will (was: [ANN] Introducing Scala, step 1)i: 00489, Steven E. Harris |
| Next by Thread: | Fwd: [ANN] Introducing Scala, step 1: 00489, Jim Menard |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |