| [#1271] | project: api | priority: low | category: missing feature | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Iulian | Burak | moved to trac | 2007-08-09 10:32:12.0 | |
| subject | [contrib #724] A mechanism to match Streams lazily | |||
| code |
Currently it's possible to match using Seq, likewise:
<pre>s match {
case Seq(...) =>
...
}</pre>
But this forces the evaluation of the entire Stream. |
|||
| what happened | Forces the evaluation of the entire stream. This is an undesired effect when using Streams. |
|||
| what expected | Something like..
s match {
case Stream(...) =>
...
}
This will pattern match against Stream(...) using regular Scala patterns, while forcing the evaluation of only the necessary number of elements.
Thus for example,
s match {
case Stream(A, B, _*) => ...
}
Would only force the evaluation of the first 2 elements in the stream |
|||
| [back to overview] | ||||
| Iulian edited on 2007-08-09 10:32:56.0 |
| For a patch, see the discussion at: http://www.nabble.com/-scala--Better-matching-with-unapplySeq-tf4064610.html#a11548771 |
| Gilles edited on 2007-08-29 10:23:03.0 |