This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Adding ??? to Predef?

103 replies
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.

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

LouisB
Joined: 2009-11-25,
User offline. Last seen 2 years 46 weeks ago.
Re: Adding ??? to Predef?
Brilliant, I'd love it personally. So often I want to get some outline structure to compile then come back and fill in some details - nice idea, I'd use it immediately!
David Hall 4
Joined: 2009-08-21,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?

+1. FWIW, I've been using TODO, which might be a little more transparent...

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
I like it too. Just wondering if it is the most general solution or if there might be related functionality which can be folded into it ...
Jon-Anders Teigen
Joined: 2010-01-02,
User offline. Last seen 44 weeks 1 day ago.
Re: Adding ??? to Predef?

I would prefer you didn't commit this for a couple of reasons.

* 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

On Oct 1, 2011, at 10:46 AM, David Hall wrote:

> +1. FWIW, I've been using TODO, which might be a little more transparent...
>

Ismael Juma 2
Joined: 2011-01-22,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?

I like TODO better myself. Apart from being more readable, most IDEs have support for showing all TODOs in a codebase.

On 1 Oct 2011 09:46, "David Hall" <dlwh [at] cs [dot] berkeley [dot] edu> wrote:
> +1. FWIW, I've been using TODO, which might be a little more transparent...
>
> -- David
>
> On Sat, Oct 1, 2011 at 1:13 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> 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
>>
Chris Twiner
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?

+1

On Oct 1, 2011 2:03 PM, "Ismael Juma" <ismael [at] juma [dot] me [dot] uk> wrote:
> I like TODO better myself. Apart from being more readable, most IDEs have
> support for showing all TODOs in a codebase.
> On 1 Oct 2011 09:46, "David Hall" <dlwh [at] cs [dot] berkeley [dot] edu> wrote:
>> +1. FWIW, I've been using TODO, which might be a little more
> transparent...
>>
>> -- David
>>
>> On Sat, Oct 1, 2011 at 1:13 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch>
> 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
>>>
Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Adding ??? to Predef?
+1 for naming it TODO
If I wanted a glut of extra symbols in my code, we have libraries which can do that :)

On 1 October 2011 13:13, Chris Twiner <chris [dot] twiner [at] gmail [dot] com> wrote:

+1

On Oct 1, 2011 2:03 PM, "Ismael Juma" <ismael [at] juma [dot] me [dot] uk> wrote:
> I like TODO better myself. Apart from being more readable, most IDEs have
> support for showing all TODOs in a codebase.
> On 1 Oct 2011 09:46, "David Hall" <dlwh [at] cs [dot] berkeley [dot] edu> wrote:
>> +1. FWIW, I've been using TODO, which might be a little more
> transparent...
>>
>> -- David
>>
>> On Sat, Oct 1, 2011 at 1:13 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch>
> 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
>>>


extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Adding ??? to Predef?

I also prefer TODO.

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Adding ??? to Predef?

On Sat, Oct 1, 2011 at 2:25 PM, Kevin Wright wrote:
> +1 for naming it TODO
> If I wanted a glut of extra symbols in my code, we have libraries which can
> do that :)

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

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: Adding ??? to Predef?
I'm still in favor of TODO or `undefined`.  ??? is just asking for anti-operator-overloading-ite criticism.
In a similar vein, I have a project that allows me to write  `O NOES !!` for these types of methods, which, although more characters, is much more fun to write.

On Sat, Oct 1, 2011 at 8:52 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
On Sat, Oct 1, 2011 at 2:25 PM, Kevin Wright <kev [dot] lee [dot] wright [at] gmail [dot] com> wrote:
> +1 for naming it TODO
> If I wanted a glut of extra symbols in my code, we have libraries which can
> do that :)

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

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Adding ??? to Predef?

On Sat, Oct 1, 2011 at 3:04 PM, Josh Suereth wrote:
> I'm still in favor of TODO or `undefined`.  ??? is just asking for
> anti-operator-overloading-ite criticism.out ToDo

What about ToDo? I guess I just don't like the all-caps style of TODO.

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Adding ??? to Predef?

I like ToDo better.

Another possibility is ToodleOo, since you're throwing an exception
you may as well say goodbye.

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Adding ??? to Predef?

On Sat, Oct 1, 2011 at 09:52, martin odersky wrote:
> On Sat, Oct 1, 2011 at 2:25 PM, Kevin Wright wrote:
>> +1 for naming it TODO
>> If I wanted a glut of extra symbols in my code, we have libraries which can
>> do that :)
>
> 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.

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.

Ismael Juma 2
Joined: 2011-01-22,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?

On 1 Oct 2011 14:23, "Paul Phillips" <paulp [at] improving [dot] org> wrote:
>
> I like ToDo better.

Me too.

Best,
Ismael

LLemiengre
Joined: 2008-08-19,
User offline. Last seen 4 years 4 weeks ago.
Re: Adding ??? to Predef?
I don't like 'ToDo', I frequently use todo as a variable name it would be confusing, '???' would be better or 'NotImplemented'
Lieven.

On Sat, Oct 1, 2011 at 5:16 PM, Ismael Juma <ismael [at] juma [dot] me [dot] uk> wrote:

On 1 Oct 2011 14:23, "Paul Phillips" <paulp [at] improving [dot] org> wrote:
>
> I like ToDo better.

Me too.

Best,
Ismael


Doug Tangren
Joined: 2009-12-10,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
On Sat, Oct 1, 2011 at 12:39 PM, Lieven Lemiengre <lieven [dot] lemiengre [at] gmail [dot] com> wrote:
I don't like 'ToDo', I frequently use todo as a variable name it would be confusing, '???' would be better or 'NotImplemented'

with _ already being used as a "place holder" for values and for denoting a point for completion in curried functions in scala, why not build the idea of placeholder with 
def foo(x: String): String = _?  // denotes an unknown placeholderor de foo(x: String): String = _! // denotes an explosive placeholder (throws an exception!)
Jon Steelman
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: Adding ??? to Predef?
I prefer ??? over TODO/ToDo.
Might be nice if ??? optionally permitted a comment parameter to add detail about what needs to be done or how it can be done. The comment parameter could be used by the compiler switch that Daniel suggested and perhaps other ways.
Thanks,Jon
Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Adding ??? to Predef?
I'd say that TODO, or NOTIMPL, or equivalent - in all caps - works precisely *because* it's so jarring.
The justification for ??? is that it stands out visually.  Using ALL CAPS achieves the same goal, especially given that Scala doesn't already use this convention for constants.


It gets even better with an optional string argument:
    def foo(x: String): String = TODO("should return a foo'd "+x)



On 1 October 2011 17:39, Lieven Lemiengre <lieven [dot] lemiengre [at] gmail [dot] com> wrote:
I don't like 'ToDo', I frequently use todo as a variable name it would be confusing, '???' would be better or 'NotImplemented'
Lieven.

On Sat, Oct 1, 2011 at 5:16 PM, Ismael Juma <ismael [at] juma [dot] me [dot] uk> wrote:

On 1 Oct 2011 14:23, "Paul Phillips" <paulp [at] improving [dot] org> wrote:
>
> I like ToDo better.

Me too.

Best,
Ismael






Erik Engbrecht
Joined: 2008-12-19,
User offline. Last seen 3 years 18 weeks ago.
Re: Adding ??? to Predef?

If this is implemented, could it be accompanied by a compiler warning for all the ??? or TODO or whatever methods?

Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Re: Adding ??? to Predef?

Why not an @Todo annotation that forbids method implementation until removed, issues a compile-time warning and adds a throw as the method body?

On Oct 1, 2011 7:28 PM, "Kevin Wright" <kev [dot] lee [dot] wright [at] gmail [dot] com> wrote:
> I'd say that TODO, or NOTIMPL, or equivalent - in all caps - works precisely
> *because* it's so jarring.
>
> The justification for ??? is that it stands out visually. Using ALL CAPS
> achieves the same goal, especially given that Scala doesn't already use this
> convention for constants.
>
>
> It gets even better with an optional string argument:
>
> def foo(x: String): String = TODO("should return a foo'd "+x)
>
>
>
> On 1 October 2011 17:39, Lieven Lemiengre <lieven [dot] lemiengre [at] gmail [dot] com>wrote:
>
>> I don't like 'ToDo', I frequently use todo as a variable name it would be
>> confusing, '???' would be better or 'NotImplemented'
>>
>> Lieven.
>>
>>
>> On Sat, Oct 1, 2011 at 5:16 PM, Ismael Juma <ismael [at] juma [dot] me [dot] uk> wrote:
>>
>>> On 1 Oct 2011 14:23, "Paul Phillips" <paulp [at] improving [dot] org> wrote:
>>> >
>>> > I like ToDo better.
>>>
>>> Me too.
>>>
>>> Best,
>>> Ismael
>>>
>>
>>
Archontophoenix Quar
Joined: 2011-04-01,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?

I habitually use TODO, but ??? does look more visually distinctive.
Maybe it's time to switch.

In the same vein:

def `!!!`: Nothing = throw new AssertionError("Can't get here")

Easier to spot than "_!"?

A

On Sat, Oct 1, 2011 at 5:52 AM, martin odersky wrote:
> On Sat, Oct 1, 2011 at 2:25 PM, Kevin Wright wrote:
>> +1 for naming it TODO
>> If I wanted a glut of extra symbols in my code, we have libraries which can
>> do that :)
>
> 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
>

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
I would suggest ??? with an optional message.

While ‘ToDo’ and others could work too, the fact that almost everybody out there took ??? instead of those speaks for itself.
dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: Adding ??? to Predef?

On Sat, Oct 1, 2011 at 15:30, Archontophoenix Quar wrote:
> I habitually use TODO, but ??? does look more visually distinctive.
> Maybe it's time to switch.
>
> In the same vein:
>
>   def `!!!`: Nothing = throw new AssertionError("Can't get here")

That one *is* part of Akka, though deprecated.

gkossakowski
Joined: 2010-03-11,
User offline. Last seen 33 weeks 5 days ago.
Re: Adding ??? to Predef?
On 1 October 2011 10:13, martin odersky <martin [dot] odersky [at] epfl [dot] ch> 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?

+1
Regarding all other proposals. Download slides for Martin's talk: http://assets.en.oreilly.com/1/event/61/Future-proofing%20Collections_%20From%20Mutable%20to%20Persistent%20to%20Parallel%20Presentation.pdf
Scroll to "Outline of Class Coder". You'll see ?? being used there. Replace it by any other proposed name and you see that it looks much worse.
--
Grzegorz Kossakowski

LouisB
Joined: 2009-11-25,
User offline. Last seen 2 years 46 weeks ago.
Re: Adding ??? to Predef?
Like the general idea, as to the exact name I've not a strong opinion, but one thing is that for example I might reserve "Todo" within general comments (in the middle of implemented functions etc) that require more work and it would be nice to be able to search for something unique in the code that won't also find all other general todos in the code as well. I suppose there could be both symbolic and descriptive alternatives, what's quite nice about ??? is that it's visually eye catching too (and fairly self-evident as to meaning?). Be nice to locate all unimplemented functions alone by searching from something with few or zero false positives.

Ittay Dror 2
Joined: 2010-05-05,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
What is wrong with 'error("todo")'? (I don't think the fact it throws a RuntimeException and not UnsupportedOperationException matters here)

But if something is to be added, I prefer viktorklang's @Todo suggestion.

On Saturday, October 1, 2011 11:13:42 AM UTC+3, 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

Jeff Olson
Joined: 2011-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
Short response: Yes please!! I much prefer ??? but anything would be better than nothing.

Longer response: For what it's worth, Haskell defines such a method (called 'undefined') in it's prelude, and it's endlessly useful. I tried using 'undefined' for awhile in my scala code but it didn't look quite right. I then tried both TODO and UNDEFINED, but I found the all caps too jarring (especially when I was stubbing out a class and all methods but one or two where "UNDEFINED"). I saw Martin use ??? back at Scala Days and I thought that it was brilliant. I have been using it ever since, and I love it. My exact implementation differs a little bit:

  class UndefinedError(msg: String) extends Error(msg)
  def undefined(msg: String) = throw new UndefinedError(msg)
  def ??? = undefined("undefined")

I preferred defining a new exception class rather than use UnsupportedOperationException because I didn't want to insinuate that the method was permanently unsupported, only that it hadn't been defined yet. Finally, if I wanted to attach an error message I found
  def foo = undefined("foo is still undefined!")
to be more readable than
  def foo = ???("foo is still undefined!")

But I also understand that adding three new symbols to the Predef instead of one, is much more controversial.

-Jeff
wookietreiber
Joined: 2011-04-24,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Adding ??? to Predef?

Personally, I find the idea of `???` intriguing, even more than `TODO`.
It's true, that IDEs highlight TODOs, but as far as I know, some of them
only within comments. `???` just stands out more, is intuitive and will
propably be not used by any other library. `ToDo` on the other hand does
not stand out that much and looks more like an ordinary method or object.

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

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Re: Adding ??? to Predef?
And it's not just IDE's.  CI systems, sbt and maven plugins that generate reports at build time, me using grep on the command line, etc. etc.  I quite like the idea of being able to search for both this form of TODO and TODO in comments in a single pass
There's a lot to be said for working with a convention that's already widely used and supported.


On 2 October 2011 10:20, wookietreiber <kizkizzbangbang [at] googlemail [dot] com> wrote:
Personally, I find the idea of `???` intriguing, even more than `TODO`.
It's true, that IDEs highlight TODOs, but as far as I know, some of them
only within comments. `???` just stands out more, is intuitive and will
propably be not used by any other library. `ToDo` on the other hand does
not stand out that much and looks more like an ordinary method or object.

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




loverdos
Joined: 2008-11-18,
User offline. Last seen 2 years 27 weeks ago.
Re: Adding ??? to Predef?

I definitely vote for the addition of something like that in Predef.

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
>

Peter C. Chapin 2
Joined: 2011-01-07,
User offline. Last seen 42 years 45 weeks ago.
RE: Re: Adding ??? to Predef?

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

 

 

From: scala-internals [at] googlegroups [dot] com [mailto:scala-internals [at] googlegroups [dot] com] On Behalf Of Kevin Wright
Sent: Sunday, October 02, 2011 05:26
To: scala-internals [at] googlegroups [dot] com
Subject: Re: [scala-internals] Re: Adding ??? to Predef?

 

And it's not just IDE's.  CI systems, sbt and maven plugins that generate reports at build time, me using grep on the command line, etc. etc.  I quite like the idea of being able to search for both this form of TODO and TODO in comments in a single pass

 

There's a lot to be said for working with a convention that's already widely used and supported.

 

 

wookietreiber
Joined: 2011-04-24,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Adding ??? to Predef?

iirc eclipse has configurable, priority-based highlighting for commented stuff,
TODO is normal priority, FIXME is high priority and CHANGE or so was low
priority. but thats just eclipse ...

On Sun, Oct 02, 2011 at 08:27:35AM -0400, Peter C. Chapin wrote:
> 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
>
>
>
>
>
> From: scala-internals [at] googlegroups [dot] com
> [mailto:scala-internals [at] googlegroups [dot] com] On Behalf Of Kevin Wright
> Sent: Sunday, October 02, 2011 05:26
> To: scala-internals [at] googlegroups [dot] com
> Subject: Re: [scala-internals] Re: Adding ??? to Predef?
>
>
>
> And it's not just IDE's. CI systems, sbt and maven plugins that generate
> reports at build time, me using grep on the command line, etc. etc. I quite
> like the idea of being able to search for both this form of TODO and TODO in
> comments in a single pass
>
>
>
> There's a lot to be said for working with a convention that's already widely
> used and supported.
>
>
>
>
>

Peter C. Chapin 2
Joined: 2011-01-07,
User offline. Last seen 42 years 45 weeks ago.
RE: Re: Adding ??? to Predef?

I just noticed that jEdit's TaskList plug-in searches for ??? out of the box (along with TODO, FIXME, and various others).

Peter

> -----Original Message-----
> From: scala-internals [at] googlegroups [dot] com [mailto:scala-
> internals [at] googlegroups [dot] com] On Behalf Of wookietreiber
> Sent: Sunday, October 02, 2011 08:56
> To: scala-internals [at] googlegroups [dot] com
> Subject: Re: [scala-internals] Re: Adding ??? to Predef?
>
> iirc eclipse has configurable, priority-based highlighting for commented stuff,
> TODO is normal priority, FIXME is high priority and CHANGE or so was low
> priority. but thats just eclipse ...

Chris Marshall
Joined: 2009-06-17,
User offline. Last seen 44 weeks 3 days ago.
RE: Adding ??? to Predef?
No-one seems to have pointed out that ??? (or TODO, or whatever we call it) is *not* the same as what a thrown UnsupportedOperationException signifies. An unsupported operation is what it says on the tin, an operation which is not supported. For example, a Collections.unmodifiableList returns a List which throws a UOE when you try and mutate it. This does not mean that this functionality is not yet implemented. I would personally prefer a bespoke (runtime) exception type NotYetImplementedException, so there is zero ambiguity.
Furthermore, the implementation makes no distinction between those as-yet-unimplemented features which should cause a program to fail, and those which should not. For example, I have implemented both todo and ??? as follows:
    def ??? = throw new NotYetImplementedException
    def todo(msg: String = "", throwsException: Boolean = true) = if (throwsException) throw new NotYetImplementedException(msg)
This then gets used as follows:
    todo(msg = "should really update state at this point", throwsException = false)
Chris  

> From: martin [dot] odersky [at] epfl [dot] ch
> Date: Sat, 1 Oct 2011 10:13:42 +0200
> Subject: [scala-internals] Adding ??? to Predef?
> To: scala-internals [at] googlegroups [dot] com
>
> 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
alexcozzi
Joined: 2011-04-05,
User offline. Last seen 1 year 27 weeks ago.
Re: Adding ??? to Predef?
I really like ??? instead of TODO or anything else. It is very "scala-ish" and intuitive at the same time. While I can see the arguments for TODO being consistent with pre-existing approaches I repeatedly loved Scala for being a bit different and feeling a lot better after you get used to it. And I am not too worried about the specific implementation, since this is really supposed to be just a placeholder it needs to be visually salient and easy to type. I found ??? a great way to stub things out.
So +1 from me.
Alex
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Adding ??? to Predef?

On Sun, Oct 2, 2011 at 6:24 PM, Chris Marshall wrote:
> No-one seems to have pointed out that ??? (or TODO, or whatever we call it)
> is *not* the same as what a thrown UnsupportedOperationException signifies.
> An unsupported operation is what it says on the tin, an operation which is
> not supported. For example, a Collections.unmodifiableList returns a List
> which throws a UOE when you try and mutate it. This does not mean that this
> functionality is not yet implemented. I would personally prefer a bespoke
> (runtime) exception type NotYetImplementedException, so there is zero
> ambiguity.
> Furthermore, the implementation makes no distinction between those
> as-yet-unimplemented features which should cause a program to fail, and
> those which should not. For example, I have implemented both todo and ??? as
> follows:
>     def ??? = throw new NotYetImplementedException
>     def todo(msg: String = "", throwsException: Boolean = true) = if
> (throwsException) throw new NotYetImplementedException(msg)
> This then gets used as follows:
>     todo(msg = "should really update state at this point", throwsException =
> false)
> Chris
>
I agree that using UnsupportedOperationException is misleading. Let's use
NotYetImplementedException.

Cheers

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Adding ??? to Predef?
Perhaps we can do the same with the package as well.  Instead of using `predef`, I'd have no problem with
import literate.???orimport scala.literate.TODO

Or any other package name that makes sense.  I like "literate" because it gives a bit of wiggle-room for adding other similar features.
The risk of name clashes from anything in predef is always high.  I'm fairly sure Paul already ran into that problem in the past; trying to implement "7 times { someBodyStuff }" to avoid the boxing penalty when using ranges, and clashed with one of the test frameworks.

On 2 October 2011 18:30, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
On Sun, Oct 2, 2011 at 6:24 PM, Chris Marshall <oxbow_lakes [at] hotmail [dot] com> wrote:
> No-one seems to have pointed out that ??? (or TODO, or whatever we call it)
> is *not* the same as what a thrown UnsupportedOperationException signifies.
> An unsupported operation is what it says on the tin, an operation which is
> not supported. For example, a Collections.unmodifiableList returns a List
> which throws a UOE when you try and mutate it. This does not mean that this
> functionality is not yet implemented. I would personally prefer a bespoke
> (runtime) exception type NotYetImplementedException, so there is zero
> ambiguity.
> Furthermore, the implementation makes no distinction between those
> as-yet-unimplemented features which should cause a program to fail, and
> those which should not. For example, I have implemented both todo and ??? as
> follows:
>     def ??? = throw new NotYetImplementedException
>     def todo(msg: String = "", throwsException: Boolean = true) = if
> (throwsException) throw new NotYetImplementedException(msg)
> This then gets used as follows:
>     todo(msg = "should really update state at this point", throwsException =
> false)
> Chris
>
I agree that using UnsupportedOperationException is misleading. Let's use
NotYetImplementedException.

Cheers

Jeff Olson
Joined: 2011-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
If we are going to use a new Exception type I still prefer UndefinedException or UndefinedOperationException as I mentioned above. Both roll off the tongue a little easier than NotYetImplementedException. -Jeff
Jon Steelman
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: Adding ??? to Predef?
Perhaps you would like UnimplementedException over NotYetImplementedException?
Jon

On Sun, Oct 2, 2011 at 1:55 PM, Jeff Olson <jdolson [at] rgmadvisors [dot] com> wrote:
If we are going to use a new Exception type I still prefer UndefinedException or UndefinedOperationException as I mentioned above. Both roll off the tongue a little easier than NotYetImplementedException. -Jeff
DaveScala
Joined: 2011-03-18,
User offline. Last seen 1 year 21 weeks ago.
Re: Adding ??? to Predef?

I vote for:

def ??? : Nothing = throw new NotYetImplementedException

sjrd
Joined: 2011-04-09,
User offline. Last seen 51 weeks 2 days ago.
Re: Re: Adding ??? to Predef?
This feature would be SO great! Especially for teaching purposes.

For that reason, I largely prefer ??? over TODO or anything else. In particular, the @Todo is just not adapted to teaching. ??? seams to be the most natural way of expressing the idea, and is so easy to write. Besides, it looks better on slides, as was already mentioned.

For the same reason, I like it being in Predef, so that we don't need to have a special import for this stuff when we give code with holes to be filled by students.

Also I'd vote for NotYetImplementedException.

Sébastien
Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: Re: Adding ??? to Predef?
I'm actually swinging ever more in favour of @Todo, the more I think about it.
Granted, it requires additional support, but it *does* come with the advantage that the generated message could embed the method name in question... Unless this is something that the upcoming reflection library could also handle, in which case I'm dead set against to any unnecessary changes in the compiler :)


On 2 October 2011 20:16, Sébastien Doeraene <sjrdoeraene [at] gmail [dot] com> wrote:
This feature would be SO great! Especially for teaching purposes.

For that reason, I largely prefer ??? over TODO or anything else. In particular, the @Todo is just not adapted to teaching. ??? seams to be the most natural way of expressing the idea, and is so easy to write. Besides, it looks better on slides, as was already mentioned.

For the same reason, I like it being in Predef, so that we don't need to have a special import for this stuff when we give code with holes to be filled by students.

Also I'd vote for NotYetImplementedException.

Sébastien



--
Kevin Wright
mail: kevin [dot] wright [at] scalatechnology [dot] com
gtalk / msn : kev [dot] lee [dot] wright [at] gmail [dot] com quora: http://www.quora.com/Kevin-Wrightgoogle+: http://gplus.to/thecoda
kev [dot] lee [dot] wright [at] gmail [dot] com twitter: @thecoda
vibe / skype: kev.lee.wrightsteam: kev_lee_wright
"My point today is that, if we wish to count lines of code, we should not regard them as "lines produced" but as "lines spent": the current conventional wisdom is so foolish as to book that count on the wrong side of the ledger" ~ Dijkstra
Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: Re: Adding ??? to Predef?

On Sun, Oct 2, 2011 at 9:32 PM, Kevin Wright wrote:
> I'm actually swinging ever more in favour of @Todo, the more I think about
> it.
> Granted, it requires additional support, but it *does* come with the
> advantage that the generated message could embed the method name in
> question... Unless this is something that the upcoming reflection library
> could also handle, in which case I'm dead set against to any unnecessary
> changes in the compiler :)

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

Andrew Forrest
Joined: 2008-12-20,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
On 02/10/2011 18:58, Jon Steelman wrote:
v0H-x2BPX+iAWxtFg3eXiKOg [at] mail [dot] gmail [dot] com" type="cite">Perhaps you would like UnimplementedException over NotYetImplementedException?
.NET BCL uses ‘NotImplementedException’ (to mean the same thing: something which does not yet have an implementation, but which should do). Might be good to use the same name for the same concept?

–Andrew
hseeberger
Joined: 2008-12-27,
User offline. Last seen 1 year 25 weeks ago.
Re: Adding ??? to Predef?
Such a lively discussion about such a small feature …
Nevertheless I like it. Go for ???. Or TODO, because that's familiar for lots of Java developers. Both are unlikely to be used for any real-world cases. ToDo looks like something someone might actually want to come up with, for example in an application for … a todo list.
Heiko

--
Heiko Seeberger
Twitter: hseeberger
Blog: heikoseeberger.name
Company: Typesafe - Enterprise-Grade Scala from the Experts
Author of Durchstarten mit Scala, a German tutorial-style Scala book


On Oct 1, 2011, at 4:13 AM, 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

daniel
Joined: 2008-08-20,
User offline. Last seen 44 weeks 14 hours ago.
Re: Adding ??? to Predef?
I have actually used ToDo as a valid identifier in an application.  TODO is also a potentially useful identifier when working with Java.  However, ??? is pretty much guaranteed never to be used by any sane-thinking library designer, so I'm going to come out in favor of it just on that basis alone.  Normally, I'm pretty opposed to gratuitous operator overloading.  However, in this case, an operator is the best choice precisely because it is normally the worst choice.  The point is to be unambiguously unusual, and this fits the bill.

I'm pretty strongly opposed to @Todo.  I'm opposed to annotations in general, but this one would be particularly onerous since it adds a type rule associated with the annotation (at least two rules, actually).  We already have a few others that do this (@BeanProperty, @deprecated), and I really would be much happier if we didn't compound the issue by adding another.  The advantage of having the compiler warn in this case is far outweighed by the fact that you would be adding complexity to the core language.  Grep is easy to use, and I think we're all in agreement that ??? is a fairly distinct token (more distinct, in fact, than TODO).

Daniel

On Mon, Oct 3, 2011 at 5:12 PM, Heiko Seeberger <heiko [dot] seeberger [at] googlemail [dot] com> wrote:
Such a lively discussion about such a small feature …
Nevertheless I like it. Go for ???. Or TODO, because that's familiar for lots of Java developers. Both are unlikely to be used for any real-world cases. ToDo looks like something someone might actually want to come up with, for example in an application for … a todo list.
Heiko

--
Heiko Seeberger
Twitter: hseeberger
Blog: heikoseeberger.name
Company: Typesafe - Enterprise-Grade Scala from the Experts
Author of Durchstarten mit Scala, a German tutorial-style Scala book


On Oct 1, 2011, at 4:13 AM, 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


etorreborre 2
Joined: 2011-02-23,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
Just to add my voice to the concert:
  • I prefer ??? over TODO or ToDo
  • I like the proposal to have ??? as an alias of "undefined" and a simple UndefinedException being thrown. I think this is where we would get good inspiration from Haskell and we could reuse the "undefined" behavior in lots of expressions to show the effects of laziness for example. To me, ??? is more than just "NotYetImplemented"
  • ??? is not used in specs/specs2 (and not used in any specification I read)
Eric.
daniel
Joined: 2008-08-20,
User offline. Last seen 44 weeks 14 hours ago.
Re: Re: Adding ??? to Predef?
I did a recursive grep (well, ack actually) over my entire hard drive looking for ???.  Now, I don't have everything in the Scala ecosystem just living on my system, but I do have a pretty sizable sampling.  Enough to discover interesting things though (like the fact that Akka's only use of the token is in a FIXME comment that may or may not still be current).

Results: the only Scala project I have that uses ??? as an identifier is Scala itself, and I'd be willing to bet that's all Martin's doing.  (the definitions are equivalent to what he was proposing for Predef)

Daniel

On Mon, Oct 3, 2011 at 6:02 PM, etorreborre <etorreborre [at] gmail [dot] com> wrote:
Just to add my voice to the concert:
  • I prefer ??? over TODO or ToDo
  • I like the proposal to have ??? as an alias of "undefined" and a simple UndefinedException being thrown. I think this is where we would get good inspiration from Haskell and we could reuse the "undefined" behavior in lots of expressions to show the effects of laziness for example. To me, ??? is more than just "NotYetImplemented"
  • ??? is not used in specs/specs2 (and not used in any specification I read)
Eric.

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Re: Adding ??? to Predef?

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 }

Jorge Ortiz
Joined: 2008-12-16,
User offline. Last seen 29 weeks 3 days ago.
Re: Re: Adding ??? to Predef?
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.
--j

On Mon, Oct 3, 2011 at 7:32 PM, Paul Phillips <paulp [at] improving [dot] 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 }

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland