-
Notifications
You must be signed in to change notification settings - Fork 21
String.toInt, .toDouble should allow a default parameter #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-16?orig=1 |
Aaron Harnly (aaronharnly) said: |
@odersky said: numSafe[A](foo: => A): Option[A] = to deal with these situations once and for all in a systematic manner. |
@paulp said:
I agree, it's that wrapper (or something like it, and things similar to it) which I do think belong in the standard library somewhere. The mere fact that the exact same wrapping is needed in multiple places in scalac itself is a pretty reasonable argument for it, not to mention the likely requirements of the remainder of the world. "Once and for all" + "systematic" == "let's do this once for everyone..." |
@odersky said: |
@paulp said:
I'm torn, as I think there's already too much in Predef, which I would rather see broken down. This issue is well intertwined with (at least) my hopes for a) a much easier import/export mechanism b) a generalized exception handling mechanism. So it's hard to say whether I have a better idea, it depends a bit on the appropriate level of ambition. I would definitely prefer to call it "opt" though, since making this lightweight is key. Just thinking out loud now, because what better place than closed trac ticket #16 could there be for me to flesh out my ideas, but: def opt[T](f: => T)(implicit pf: PartialFunction[Either[Throwable,T]] => Boolean): Option[T] = ... The gist being that somehow a function must be supplied which partitions both return values and exceptions into Some, None, or neither (that last being exceptions which you did not opt to catch, which will simply fly right on through.) Now very nice wrappers can be written. This approach also generalizes the oft-rewritten def onull[T](x: T): Option[T] = if (x == null) None else Some(x) ...but now that could be composed with other criteria or exceptions. |
aunndroid said: |
@soc said: |
there is an active discussion on this at scala/collection-strawman#431 |
has PR now, reviewers wanted: scala/scala#6538 |
for fixing the last open two-digit Scala issue, @martijnhoekstra officially gets to wear a big, shiny golden crown whenever he wants. https://github.com/scala/bug/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc shows 16 remaining open three-digit issues, for anyone interested in earning the right to wear an only slightly smaller and slightly less jewel-encrusted crown |
Aladdin: [http://scala-webapps.epfl.ch/bugtracking/bugs/displayItem.do?id=1299 bug 1299], [http://scala-webapps.epfl.ch/bugtracking/contribs/display.do?id=773 contrib 773]
== Code ==
== What happened ==
n/a
== What expected ==
To be able to optionally provide a default value for string-to-primitive conversion methods, much like Option.get.
The text was updated successfully, but these errors were encountered: