|
Re: Another nit: msg#00450lang.scala
Hey, Tony, it is always fun to read posts by people who have experimented with their own library support! Just a couple of small notes: Tony Morris <tmorris@xxxxxxxxxxx> writes: > I have written my own cons list - it is lazily evaluated. At first it > was an experiment, but after learning more, I decided it actually has > merit over the existing Scala APIs so I took it further. Here are some > of the implicit conversions I have: By existing APIs, do you include scala.Stream, by the way? The name scala.Stream makes it hard to find for people who are looking for "Lazy List". > MyList[A] <-> scala.List[A] > MyList[A] <-> scala.Stream[A] > MyList[A] <-> scala.Iterator[A] These are generally cool, but this third one looks weird to me. Scala carefully distinguishes Iterable's from Iterator's. If you want an iterator, you send elements. Anyway, I'd love to hear how your experience goes with it. > In Scala: > > abstract class Equal[A] { > def eq (a1: A)(a2: A): Boolean = { > !(neq(a1)(a2)) > } You should name this something else, because "eq" is Scala's name for Java's "==" ! (Scala's == calls equals().) > // by the way, can you pattern match both xs1 and xs2 here? Try a match on the tuple {xs1,xs2}. Maybe that will shorten the code nicely. > But then you can get really funky within a mixin. How about the ordering > relationship? > trait Ord[A] extends Equal[A] { This one is in the library, by the way. Great minds think alike. :) -Lex |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: more fun with packing: 00450, Lex Spoon |
|---|---|
| Next by Date: | Re: Any way to cut down on memory footprint?: 00450, Lex Spoon |
| Previous by Thread: | Re: Another niti: 00450, Tony Morris |
| Next by Thread: | Re: Another nit: 00450, Tony Morris |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |