/** Throws an UnsupportedOperationException.
* Convenient as a placeholder for a missing right-hand-side of a method.
*/
def ??? : Nothing = throw new UnsupportedOperationException("not implemented")
I have been defining this method myself in more and more projects
because I find it both cute and convenient to use
def foo(x: String): String = ???
for a not-yet implemented method. Also makes for a great teaching
tool. Just tell you class to replace the ???'s.
What do you think?
Cheers
-- Martin
-- David
* I am not sure ??? is so much better than for example a method called "notImplemented", "TODO" or something else that it warrants the introduction of a new symbolic method globally available in all scala programs.
* I dislike encouraging the use of UnsupportedOperationException. Like casting (asInstanceOf[T] vs (T) from java) it really shouldn't be used much and its ok that it screams at you and is somewhat clumsy to type.
* If one really wants this and like using UnsupportedOperations its as simple as adding it to your own package object with the added benefit that you can remove it too when you don't want it anymore.
I wouldn't mind having it available in a trait, ready to be mixed into my own package object for example in the context of teaching, but I really don't want a ??? lurking among the !!, !? and ?s and all the other symbols in my production code.
/j
I like TODO better myself. Apart from being more readable, most IDEs have support for showing all TODOs in a codebase.
+1
I agree that we should generally try to set a good example wrt
symbolic operators. TODO would be fine for me as well. But I find ???
works visually better for me, and I believe it's pretty easy to guess
what ??? could be, unlike some of the other symblic operators that we
come across.
I'd be interested in people trying out both variants in their code and
then reporting which works better for them. I find ??? easier on the
eye than TODO
and also easier to indicate that something is missing. TODO looks too
much like a constant for me.
Cheers
-- Martin
Cheers
-- Martin
--
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967
Does tend to match up with reality though.
What about ToDo? I guess I just don't like the all-caps style of TODO.
-- Martin
Another possibility is ToodleOo, since you're throwing an exception
you may as well say goodbye.
I find ??? works better visually -- alphanumeric identifiers just
look like business as usual. Syntax highlighting could compensate for
that, but demanding increased support kind of goes against the very
spirit of the brevity of ??? or TODO.
I don't like ToDo. While TODO looks like a Java constant, ToDo looks
like a *Scala* constant or class. TODO stands out much better than
ToDo. Besides, it looks better on slides.
I'm not sure about adding it to predef, particularly "???", for which
I'd check Scalaz, Unfiltered, Dispatcher, Akka and Specs before
trusting it was not used.
Finally, if this gets added at all, there *must* be a compiler switch
that would turn it into a compiler error. Sure, unit tests ought to
catch them all, but that presumes all unit tests were written in first
place. I don't care much for a compiler switch that changes the
meaning of a simple, valid, Scala definition, but given the incentive
this would cause, having some tool to cope with the downsides would be
very desirable.
--
Daniel C. Sobral
I travel to the future all the time.
On 1 Oct 2011 14:23, "Paul Phillips" <pa...@improving.org> wrote:
>
> I like ToDo better.
Me too.
Best,
Ismael
I don't like 'ToDo', I frequently use todo as a variable name it would be confusing, '???' would be better or 'NotImplemented'
Why not an @Todo annotation that forbids method implementation until removed, issues a compile-time warning and adds a throw as the method body?
In the same vein:
def `!!!`: Nothing = throw new AssertionError("Can't get here")
Easier to spot than "_!"?
A
That one *is* part of Akka, though deprecated.
If people don't hold me back I will commit the following addition to Predef.
/** Throws an UnsupportedOperationException.
* Convenient as a placeholder for a missing right-hand-side of a method.
*/
def ??? : Nothing = throw new UnsupportedOperationException("not implemented")
I have been defining this method myself in more and more projects
because I find it both cute and convenient to use
def foo(x: String): String = ???
for a not-yet implemented method. Also makes for a great teaching
tool. Just tell you class to replace the ???'s.
What do you think?
If people don't hold me back I will commit the following addition to Predef./** Throws an UnsupportedOperationException.
* Convenient as a placeholder for a missing right-hand-side of a method.
*/
def ??? : Nothing = throw new UnsupportedOperationException("not implemented")I have been defining this method myself in more and more projects
because I find it both cute and convenient to usedef foo(x: String): String = ???
for a not-yet implemented method. Also makes for a great teaching
tool. Just tell you class to replace the ???'s.What do you think?
Cheers
-- Martin
The question is, how do you choose? Do you want to dictate, as the main
scala developers, with propably the best knowledge about the language or
do you want to let the people choose, i.e. vote?
I would prefer a vote based on liquid democracy [1], not just for this one,
but for other decisions about the language, too. Let the people decide and,
if they are unsure, delegate the vote to someone else. Gathering ideas here
is a very good thing as a base for pros and cons for each possibility of a
vote.
[1] http://en.wikipedia.org/wiki/Liquid_democracy#Delegated_voting
--
best regards
Christian Krause aka wookietreiber
In the past, I have personally tried and not settled among these:
- ??? (coincidentally with 3 question marks)
- NotImplementedYet
- NIY_! (the ! is to bring attention)
with an optional string parameter that contributes to the exception message.
My 2c
Christos
On Oct 1, 2011, at 11:13, martin odersky wrote:
> If people don't hold me back I will commit the following addition to Predef.
>
> /** Throws an UnsupportedOperationException.
> * Convenient as a placeholder for a missing right-hand-side of a method.
> */
> def ??? : Nothing = throw new UnsupportedOperationException("not implemented")
>
> I have been defining this method myself in more and more projects
> because I find it both cute and convenient to use
>
> def foo(x: String): String = ???
>
> for a not-yet implemented method. Also makes for a great teaching
> tool. Just tell you class to replace the ???'s.
>
> What do you think?
>
> Cheers
>
> -- Martin
--
__~O
-\ <, Christos KK Loverdos
(*)/ (*) http://stepsinscala.com
Personally I’d prefer ??? over TODO or ToDo for this functionality. For one thing I use TODO in comments in a different way. Often I use them to remind myself about obscure bugs that I notice while developing code. For example “TODO: This won’t work on the last day of a leap year.” Here I’m too lazy (or too rushed) to deal with the issue right away but I don’t want to forget about it. It’s a different sort of thing than laying down a placeholder to get an otherwise unimplemented method to compile. Also I like the look of things like
val someResult = if (someCondition) doSomething() else ???
Regarding IDE support, I know that NetBeans can be configured to look for whatever character sequence you want when constructing it’s task list. It seems like it should be a simple matter to just add “???” to the list. I suppose other IDEs are similar, yes?
Peter
--
best regards
Christian Krause aka wookietreiber
---------------------------------------------
heute schon gelacht? http://www.totaberlustig.com/comics/2011-09-15-Taxi.jpg
Peter
> -----Original Message-----
> From: scala-i...@googlegroups.com [mailto:scala-
> inte...@googlegroups.com] On Behalf Of wookietreiber
> Sent: Sunday, October 02, 2011 08:56
> To: scala-i...@googlegroups.com
> Subject: Re: [scala-internals] Re: Adding ??? to Predef?
>
Cheers
-- Martin
You might want to use this for branches of a conditional or a match,
rather than an entire method body. Scala allows us to define this as a
method; we should take advantage of that. Mark it as @deprecated and
we get the compile time warnings for free (albeit through an abuse of
that mechanism.) The location of the unimplemented code is captured in
the stack trace of the thrown exception.
Oh, and for the record, I quite like ???.
-jason
Perhaps you would like UnimplementedException over NotYetImplementedException?
Also, we obviously can't ship ??? without its complement.
def ¿¿¿(body: => Any) =
try { body; false }
catch { case _: NotYetImplementedException => true }
If "???" gets added to Predef, a lot of hours will be spent explaining
the reasoning in countless discussions (in the mailing list and
otherwise). It will be /: (foldLeft) all over again. Just worse. Do
people really believe it's worth it?
Best,
Ismael
It could be treated as a zen koan.
Student: What does "???" mean?
Master: [silence]
Student: What does "???" mean???
Master: [silence]
Student: I have achieved enlightenment.
Personally I don't want to add anything to Predef until there are
better means of controlling what you get unasked from Predef.
Maybe the mystery of ??? would be reduced if there were only a one
argument version: no zero argument version. Then at least it would
usually say something like
def method = ???("???")
which is much less enigmatic.
No. Every project that likes ??? or TODO to ToDo or FightFoo could add it to its "top level package object" (one good reason to create one, if not already there).
Heiko
A
In that case any import/package level object definition destroys the
flow. When teaching I want to start from zero, and introduce only
things that people can reproduce without excessive boilerplate.
Cheers
-- Martin
--
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967
The ??? isn't the only case where this is a problem. There are lots of
other places in my Scala code where I have to do imports or annotations
which "destroy the flow". Some examples I can think of:
1. import scala.math.Numeric.ExtraImplicits._
Numeric is pretty unusable unless you can use infix operators. The
only ways to accomplish this stills adds import boilerplate to every
file or (worse) every use of a numeric type parameter.
2. import Predef.{any2stringadd => _}
When using my own Numeric I have to disable any2stringadd, this is
another per-file piece of boilerplate.
3. @specialized T:Numeric
When using a specialized Numeric type class, you have you annotate
every type parameter with specialized or else you lose the speed
benefits of specialization. This is *really* ugly!
#1 is not so bad, until you consider that you probably also had to
import scala.math.Numeric itself, so that's two lines. #3 is worse
because it's such a weird-looking import and most people don't have any
idea what it's doing.
#3 is the worst. Given that you need to specialized throughout your
critical path to see performance benefits, this ensures that all your
code becomes clunky and harder to read. Also it's easy to leave this
off by accident.
I am not arguing against ??? per se, but given that other stuff in
Predef is giving me headaches (see 2) I guess I resent the fact that
we're willing to make Predef bigger to prevent having to do a single
import. Other Scala patterns require much more onerous boiler-plate,
with no reprieve in sight.
-- Erik
a pure function that throws an exception
Sure. So we need a compromise. But there's value in standardizing,
too. My reaction is the usual: Make simple things easy and hard things
possible.
-- Martin
Sure. So we need a compromise. But there's value in standardizing,
too.
My reaction is the usual: Make simple things easy and hard things
possible.
-- Martin
+1.
for me '???' "sounds" like "wtf?".
I think an 'error("TODO")' is clearer. Especially for newcomers.
-- Sylvain HENRY PhD Student INRIA/LaBRI RunTime Team Tel: +33 (0)6-70-94-86-76 http://hsyl20.fr
I believe we want Scala to be more approachable than nuclear physics.
Best,
Ismael
If people think there is too much predefined by default, then they should start with throwing out any2stringadd and the lossy numeric conversions first.
To fan the flames a little more:This is exactly what people mean when they talk about Scala being "complex". It does not add any Martin-complexity (the spec doesn't need to change to support this), but it adds normal-people-complexity (there's a mysterious symbol that makes any piece of code magically compile, but I can't Google it to find out how it's actually working).--jOn Mon, Oct 3, 2011 at 7:46 PM, Jorge Ortiz <jorge...@gmail.com> wrote:
I'm strongly opposed to calling it ???. The jokes about Google queries just write themselves: "Scala ???".
I'm mildly opposed to putting it in Predef. There should be fewer things in Predef, not more.Other than that, I'm a big fan of TODO and frequently use it in my own code.--jOn Mon, Oct 3, 2011 at 7:32 PM, Paul Phillips <pa...@improving.org> wrote:
Since there's still a little patch of bikeshed where I can see the
original wood, I'll retract my preference for ToDo and jump on the ???
bandwagon. I was only trying to do my part not to add any more
symbolic notation to the default namespace. Now I understand that
there's still plenty of room at the top. Preference noted.
Also, we obviously can't ship ??? without its complement.
def ¿¿¿(body: => Any) =
try { body; false }
catch { case _: NotYetImplementedException => true }
I know about the dangers of symbolic operators very well. But in this
case I think we have a genuine case of a useful symbolic operator, so
I am going to stick with it.
I just added the following to Predef:
/** `???` can be used for marking methods that remain to be implemented.
* @throws A `NotImplementedError`
*/
def ??? : Nothing = throw new NotImplementedError
Best,
-- Martin
throw new NotImplementedError(msg)
I generally don't see a strong need for an additional message because
??? should be a stand-in for something you intend to implement before
you run the program. So why bother adding a message?
-- Martin
great stuff, I like it personally, ??? stands out and a new error type makes total sense too. An optional param for a message could also be useful in some situations, since say calling a service over a remote interface and getting a meaningful exception with a small message could be very handy. Anyway thumbs up from me, I really like the top down coding style in many situations, this will be perfect for that sort of thing.
Sometimes people forget to implement things, especially if they didn't think they would be called just yet.
I had understood that to be kinda the point for this, the I'll get around to this later sentiment.
I'd vote for a default parameter with a simple empty string.
def foo = ???() kind of blows the vibe, doesn't it.
If you want to be able to call it without parens, it has to be an
implicit parameter, ha ha. Otherwise it's time to enlist mr.
overload.
Cheers
-- Martin
Is there a reason why it is an Error instead of an Exception? Error has a very specific meaning in a JVM context ... I'm not sure the proposed usage reflects that.
Afaik an Error is supposed to mean “The JVM just broke and there is nothing vou can do, but instead of crashing immediately we try to give you a hint what happened.”, e. g. OutOfMemoryError.
Or is it just so that people catching Exceptions don't swallow this error?
Thanks and bye,
Simon
Error
is a subclass of Throwable
that indicates serious problems that a reasonable application should not try to catch. Most such errors are abnormal conditions. The ThreadDeath
error, though a "normal" condition, is also a subclass of Error
because most applications should not try to catch it.I was thinking that you could switch implementations if one implementation of an interface is not provided for your context.
-- Francois ARMAND http://fanf42.blogspot.com http://www.normation.com
I believe in that case the implementation should throw an
UnSupportedOperationException, not a NotImplementedError.
NotImplementedError is really akin to assert(false) and should be
treated that way.
-- Martin