Adding ??? to Predef?

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

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.

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 }

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 }

Re: Re: Adding ??? to Predef?

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).
--j

On Mon, Oct 3, 2011 at 7:46 PM, Jorge Ortiz <jorge [dot] ortiz [at] gmail [dot] 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.
--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 }


Re: Re: Adding ??? to Predef?

I don't agree because I think def x = ??? is a pretty obvious placeholder for things to come.
On the other hand the points about a classroom Predef vs a real-world Predef are quite relevant.

On 4 October 2011 01:51, Jorge Ortiz <jorge [dot] ortiz [at] gmail [dot] com> wrote:
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).
--j

On Mon, Oct 3, 2011 at 7:46 PM, Jorge Ortiz <jorge [dot] ortiz [at] gmail [dot] 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.
--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 }



Re: Re: Adding ??? to Predef?

Thanks for all the responses. It's hard to gauge the majority opinion
in situations like this (people always seem to come out more numerous
to oppose what's proposed than to support it). I think I could read
that ??? has majority support but people clearly wanted a different
exception than UnsupportedOperationException to be thrown.

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,

Re: Re: Adding ??? to Predef?

What about allowing an optional exception message?

Would be quite handy for teaching imho ...

Re: Re: Adding ??? to Predef?

On Fri, Oct 7, 2011 at 7:23 PM, Simon Ochsenreither
wrote:
> What about allowing an optional exception message?
>
How would you add that to ???. Two overloaded variants?
Note that one can alreayd write:

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?

Re: Re: Adding ??? to Predef?

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

Re: Re: Adding ??? to Predef?



On Sun, Oct 9, 2011 at 1:09 PM, Simon Ochsenreither <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
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.

I think you're confusing Error with VirtualMachineError: http://download.oracle.com/javase/7/docs/api/java/lang/VirtualMachineError.html

 

Or is it just so that people catching Exceptions don't swallow this error?


Thanks and bye,


Simon



--
Viktor Klang

Akka Tech LeadTypesafe - Enterprise-Grade Scala from the Experts

Twitter: @viktorklang

Re: Re: Adding ??? to Predef?

On Sun, Oct 9, 2011 at 1:09 PM, Simon Ochsenreither
wrote:
> 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?
>
I reasoned that a failed assertion also gives an error, and a missing
implementation is closest to a failed assertion.

Cheers

Re: Re: Adding ??? to Predef?

Simon's understanding of Error is close to mine. The javadoc says:
An 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 Errorbecause most applications should not try to catch it.

"NotImplemented" may be perfectly recoverable and I'd rather have that as an exception, a bit like java.lang.UnsupportedOperationException.
Eric.

Re: Re: Adding ??? to Predef?

Only if you truly consider a big chunk of missing implementation to be a problem from which an application could reasonably be expected to recover...  I'd say the jury's out on that one!

On 9 October 2011 23:28, etorreborre <etorreborre [at] gmail [dot] com> wrote:
Simon's understanding of Error is close to mine. The javadoc says:
An 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 Errorbecause most applications should not try to catch it.

"NotImplemented" may be perfectly recoverable and I'd rather have that as an exception, a bit like java.lang.UnsupportedOperationException.
Eric.


Re: Re: Adding ??? to Predef?

I was thinking that you could switch implementations if one implementation of an interface is not provided for your context.

Re: Re: Adding ??? to Predef?

On Mon, Oct 10, 2011 at 4:51 AM, etorreborre wrote:
> I was thinking that you could switch implementations if one implementation
> of an interface is not provided for your context.

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.

Re: Re: Adding ??? to Predef?

But isn't a method that has yet to receive implementation really much more serious in nature than a bad assertion? ??? is intended to be used as stubbed-out method bodies, no? A call-path that sinks at ??? is very serious - it needs immediate attention as the program is not (yet) complete. It's the big hole in the middle of a street - not an indication of: please choose an alternate route.
    Patrik

On Mon, Oct 10, 2011 at 9:32 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
On Mon, Oct 10, 2011 at 4:51 AM, etorreborre <etorreborre [at] gmail [dot] com> wrote:
> I was thinking that you could switch implementations if one implementation
> of an interface is not provided for your context.

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.

Re: Re: Adding ??? to Predef?

On Mon, Oct 10, 2011 at 10:20 AM, Patrik Andersson wrote:
> But isn't a method that has yet to receive implementation really much more
> serious in nature than a bad assertion? ??? is intended to be used as
> stubbed-out method bodies, no? A call-path that sinks at ??? is very serious
> - it needs immediate attention as the program is not (yet) complete. It's
> the big hole in the middle of a street - not an indication of: please choose
> an alternate route.
>     Patrik

I don't know about that. But I argued anyway that ??? should throw an
error as serious as assert whereas others were arguing that it should
throw something less serious.

Re: Re: Adding ??? to Predef?

I suppose I agree with you, that's all.

On Mon, Oct 10, 2011 at 11:50 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
On Mon, Oct 10, 2011 at 10:20 AM, Patrik Andersson <pandersson [at] gmail [dot] com> wrote:
> But isn't a method that has yet to receive implementation really much more
> serious in nature than a bad assertion? ??? is intended to be used as
> stubbed-out method bodies, no? A call-path that sinks at ??? is very serious
> - it needs immediate attention as the program is not (yet) complete. It's
> the big hole in the middle of a street - not an indication of: please choose
> an alternate route.
>     Patrik

I don't know about that. But I argued anyway that ??? should throw an
error as serious as assert whereas others were arguing that it should
throw something less serious.

Re: Adding ??? to Predef?

I agree that Error is better because a try catch clause around ???
would make no sense which is the intention of Errors: Throwables that
you should not try to catch.

"An 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.

A method is not required to declare in its throws clause any
subclasses of Error that might be thrown during the execution of the
method but not caught, since these errors are abnormal conditions that
should never occur."
see: http://download.oracle.com/javase/6/docs/api/java/lang/Error.html

So I interpret this as:
if

try{ ???
} catch {

}

makes no sense then ??? should raise an Error not an Exception.

Re: Re: Adding ??? to Predef?

If an Error is a condition that "should never occur", that suggests
that you "should never" try to run a program of which you know pieces
are missing, assuming that those missing pieces constitute an Error
(as opposed to an Exception).

Well, you know a program with pieces missing is not going to run
successfully if you launch it. Does that mean you're not seriously
trying to run it when you launch it?

Figuring out whether something is supposed to be an Error or an
Exception by parsing the Java API documentation probably ascribes to
that documentation a level of language-lawyeriness that it wasn't
designed to possess. I suspect a better guide is the fact that
AssertionError is an Error, and it does seem to me that ??? is
reasonably close in spirit to AssertionError.

A

On Mon, Oct 10, 2011 at 3:56 AM, Dave wrote:
> I agree that Error is better because a try catch clause around ???
> would make no sense which is the intention of Errors: Throwables that
> you should not try to catch.
>
> "An 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.
>
> A method is not required to declare in its throws clause any
> subclasses of Error that might be thrown during the execution of the
> method but not caught, since these errors are abnormal conditions that
> should never occur."
> see: http://download.oracle.com/javase/6/docs/api/java/lang/Error.html
>
> So I interpret this as:
> if
>
> try{ ???
> } catch {
>
> }
>
> makes no sense then ??? should raise an Error not an Exception.
>
>
>

Re: Adding ??? to Predef?

Simple answer from the docs: “An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.” In this sense I very much agree with the choice of having ??? throw an Error.

Regards,

Roland

On Oct 10, 2011, at 19:23 , Archontophoenix Quar wrote:

> If an Error is a condition that "should never occur", that suggests
> that you "should never" try to run a program of which you know pieces
> are missing, assuming that those missing pieces constitute an Error
> (as opposed to an Exception).
>
> Well, you know a program with pieces missing is not going to run
> successfully if you launch it. Does that mean you're not seriously
> trying to run it when you launch it?
>
> Figuring out whether something is supposed to be an Error or an
> Exception by parsing the Java API documentation probably ascribes to
> that documentation a level of language-lawyeriness that it wasn't
> designed to possess. I suspect a better guide is the fact that
> AssertionError is an Error, and it does seem to me that ??? is
> reasonably close in spirit to AssertionError.
>
> A
>
> On Mon, Oct 10, 2011 at 3:56 AM, Dave wrote:
>> I agree that Error is better because a try catch clause around ???
>> would make no sense which is the intention of Errors: Throwables that
>> you should not try to catch.
>>
>> "An 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.
>>
>> A method is not required to declare in its throws clause any
>> subclasses of Error that might be thrown during the execution of the
>> method but not caught, since these errors are abnormal conditions that
>> should never occur."
>> see: http://download.oracle.com/javase/6/docs/api/java/lang/Error.html
>>
>> So I interpret this as:
>> if
>>
>> try{ ???
>> } catch {
>>
>> }
>>
>> makes no sense then ??? should raise an Error not an Exception.
>>
>>
>>

Roland Kuhn
Typesafe – Enterprise-Grade Scala from the Experts
twitter: @rolandkuhn

Re: Adding ??? to Predef?

This was the basis of my previous comment:

<<I'd have gone with UnimplementedOperationException.  If it's an Error, an otherwise "reasonable application" such as some TA's ClassAssignmentRunner will have to catch it in order to fail(exercise).>>

On further reflection, I'd distinguish applications and frameworks.  Frameworks like junit or the hypothetical ClassAssignmentRunner catch throwables that well-behaved applications do not.  So I'm reconciled to an Error.

On the other hand, Errors are supposed to be mitigated at compile time, so it seems to me more obvious that compiler support of some kind is called for.  Save me from myself.

I like the idea of using @elidable to warn about leftover usages of ???.  Instead of eliding to something innocuous (BoxedUnit), elide to something that breaks the build.

If anyone still uses the MOSCOW acronym for prioritizing features, I could imagine features stubbed in this way:

def vanilla = should???
def fancy = could???

where
@elidable(level=Production, break=true, warn=500) def should??? ...
means that should??? will break the build on elision and emit warnings when the elision level is within "500" of Production.

Instead of saying a project is at "code complete" or "feature freeze", we could say a project is at elision level "Production" or "2000", and any required or desired features must be implemented, or the build will break.

I don't code this way currently, but maybe I would if I had such a facility.

People have compared the ??? exception to UnsupportedOperation, so I grepped it (in the jdk).  The paradigmatic usage is for Collections that don't honor the contract interface (like immutables throwing on add).  (Yes, in Scala this seems barbaric.)  But the exception is often a proxy for IllegalStateException or even IllegalArgument.  (E.g., Instrumentation.addTransformer perhaps should throw IllegalState.)

E.g., throw new UnsupportedOperationException("Not supported yet.");
Doesn't that mean ??? ?

I grepped my own lib code and found the same sentiment:
throw new UnsupportedOperationException("Multiline format is not yet supported");
which means I will someday, it's not like an immutable collection throwing on add.

If graphics hardware doesn't support an operation, that's clearly an UnsupportedOperation; but if I'm working out the kinks in some code and by the way, I may not find time to get around to fixing it, is that Unsupported or merely NotYetGottenAroundToItError?

I had to share MappedByteBuffer -- this is clearly IllegalState, since the code literally checks state -- but luckily the user doesn't see the inline comment about the "luser" who invokes it --
    private void checkMapped() {
        if (!isAMappedBuffer)
            // Can only happen if a luser explicitly casts a direct byte buffer
            throw new UnsupportedOperationException();
    }

Possibly, IllegalState, UnsupportedOperation, et al, should just derive from a common super, "AintGonnaHappenException".


On Mon, Oct 10, 2011 at 3:51 PM, Roland Kuhn <google [at] rkuhn [dot] info> wrote:
Simple answer from the docs: “An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch.” In this sense I very much agree with the choice of having ??? throw an Error.

Regards,

Roland

On Oct 10, 2011, at 19:23 , Archontophoenix Quar wrote:

> If an Error is a condition that "should never occur", that suggests
> that you "should never" try to run a program of which you know pieces
> are missing, assuming that those missing pieces constitute an Error
> (as opposed to an Exception).
>
> Well, you know a program with pieces missing is not going to run
> successfully if you launch it. Does that mean you're not seriously
> trying to run it when you launch it?
>
> Figuring out whether something is supposed to be an Error or an
> Exception by parsing the Java API documentation probably ascribes to
> that documentation a level of language-lawyeriness that it wasn't
> designed to possess. I suspect a better guide is the fact that
> AssertionError is an Error, and it does seem to me that ??? is
> reasonably close in spirit to AssertionError.
>
> A
>
> On Mon, Oct 10, 2011 at 3:56 AM, Dave <dave [dot] mahabiersing [at] hotmail [dot] com> wrote:
>> I agree that Error is better because a try catch clause around ???
>> would make no sense which is the intention of Errors: Throwables that
>> you should not try to catch.
>>
>> "An 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.
>>
>> A method is not required to declare in its throws clause any
>> subclasses of Error that might be thrown during the execution of the
>> method but not caught, since these errors are abnormal conditions that
>> should never occur."
>> see: http://download.oracle.com/javase/6/docs/api/java/lang/Error.html
>>
>> So I interpret this as:
>> if
>>
>> try{ ???
>> } catch {
>>
>> }
>>
>> makes no sense then ??? should raise an Error not an Exception.
>>
>>
>>

Roland Kuhn
Typesafe – Enterprise-Grade Scala from the Experts
twitter: @rolandkuhn


Re: Adding ??? to Predef?

> Figuring out whether something is supposed to be an Error or an
> Exception by parsing the Java API documentation probably ascribes to
> that documentation a level of language-lawyeriness that it wasn't
> designed to possess. I suspect a better guide is the fact that
> AssertionError is an Error, and it does seem to me that ??? is
> reasonably close in spirit to AssertionError.
>
I find all Unsupported...Exceptions also "reasonably close in spirit".
So that becomes very idiosyncratic and vague and whose spirit is it
anyway, yours, mine, everybody's? Might be different for everybody.
And referring to the fact "AssertionError is an Error" is actually
language-lawyeriness, because how do you know for sure that it is a
fact anyway? What if it is an Exception? If it quacks like a duck it
might still be an mp3-player. Asking the spirit for help has something
religious, monomanic and egocentric in your argument: "it's close to
my spirit so it must be right, follow me".

Re: Re: Adding ??? to Predef?

On 10/10/2011 04:51, etorreborre wrote:
I was thinking that you could switch implementations if one implementation of an interface is not provided for your context.

Shouldn't that be part of the application logic, with it's own exception for that ? I understood that "???" would be reserved for the unexpected missing implementation, in a oups-I-forgot-to-finish-my-implementation-after-coming-back-from-coffee way.

Thinking about that: Scala IDE may propose an "implement these traits" menu which would put "???" as body of method to implements.

Cheers,
-- 
Francois ARMAND
http://fanf42.blogspot.com
http://www.normation.com

Re: Re: Adding ??? to Predef?

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.

On Oct 7, 2011 8:02 PM, "martin odersky" <martin [dot] odersky [at] epfl [dot] ch> wrote:
> On Fri, Oct 7, 2011 at 7:23 PM, Simon Ochsenreither
> <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
>> What about allowing an optional exception message?
>>
> How would you add that to ???. Two overloaded variants?
> Note that one can alreayd write:
>
> 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

Re: Re: Adding ??? to Predef?

On Fri, Oct 7, 2011 at 11:18 AM, Chris Twiner wrote:
> 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.

Re: Re: Adding ??? to Predef?

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.

Re: Re: Adding ??? to Predef?


On Fri, Oct 7, 2011 at 10:32 AM, Louis Botterill <chillipower [dot] uk [at] gmail [dot] com> wrote:
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.

Me, too. +1.

I'd have gone with UnimplementedOperationException.  If it's an Error, an otherwise "reasonable application" such as some TA's ClassAssignmentRunner will have to catch it in order to fail(exercise).

A couple of people mentioned top-down style; I'd add that it goes to Scalability.  I looked at the slides someone pointed to, and coded the example as an exercise in TDD style: ??? is a very nice placeholder, vi-friendly (in the absence of code completion).  I will use it on an everyday basis.

It would be nice if there were a way to make it break the build, so I don't do anything stupid.  My first thought was something like @elidable, so I could raise the elision level for testing. Perhaps it would be nice to have it elide to something that necessarily fails to compile.  @elidabe(broken=true).


Re: Re: Adding ??? to Predef?

Yes, for example:
  def reflect = ???  "Martin promised to finish reflection by Halloween"

Thanks,Jon

On Fri, Oct 7, 2011 at 1:32 PM, Louis Botterill <chillipower [dot] uk [at] gmail [dot] com> wrote:
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.


Re: Re: Adding ??? to Predef?

On Tue, Oct 4, 2011 at 12:51 AM, Jorge Ortiz wrote:
> 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).

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

Re: Adding ??? to Predef?

> 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?

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

Re: Adding ??? to Predef?

People who don't understand ??? aren't reading enough comics.

A

On Mon, Oct 3, 2011 at 5:08 PM, Heiko Seeberger
wrote:
>> 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?
>
> 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
>
>

Re: Adding ??? to Predef?

My main point is that I want to use it as an effective teaching tool.

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

Re: Adding ??? to Predef?

Just want to point out that this function has uses outside of teaching too.
Sometimes it is nice to develop an algorithm top-down. Breaking the algorithm
to smaller functions, typing them and stubbing with undefined body. Those
undefined functions can be then implemented later when everything typechecks.

I quite like the name ???.

Cheers Joni

On Tuesday, October 4, 2011 10:02:58 AM UTC+3, martin odersky wrote:
My main point is that I want to use it as an effective teaching tool.

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


On Tue, Oct 4, 2011 at 4:12 AM, Archontophoenix Quar
<archo [dot] [dot] [dot] [at] gmail [dot] com> wrote:
> People who don't understand ??? aren't reading enough comics.
>
> A
>
> On Mon, Oct 3, 2011 at 5:08 PM, Heiko Seeberger
> <heiko [dot] s [dot] [dot] [dot] [at] googlemail [dot] com> wrote:
>>> 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?
>>
>> 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
>>
>>
>

--
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967

Re: Adding ??? to Predef?

+1 for ???. I don't see how one more operator can dramatically affect Scala's perceived complexity. If one sees code like this:

def foo() = ???

It is not too difficult to guess from the context that ??? means that the implementation is missing. Besides that, it is much easier to type than ToDo and since I'm using this a lot, it'll make me a more productive programmer :)

2011/10/5 Joni Freeman <freeman [dot] joni [at] gmail [dot] com>
Just want to point out that this function has uses outside of teaching too.
Sometimes it is nice to develop an algorithm top-down. Breaking the algorithm
to smaller functions, typing them and stubbing with undefined body. Those
undefined functions can be then implemented later when everything typechecks.

I quite like the name ???.

Cheers Joni

On Tuesday, October 4, 2011 10:02:58 AM UTC+3, martin odersky wrote:
My main point is that I want to use it as an effective teaching tool.

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


On Tue, Oct 4, 2011 at 4:12 AM, Archontophoenix Quar
<archo [dot] [dot] [dot] [at] gmail [dot] com> wrote:
> People who don't understand ??? aren't reading enough comics.
>
> A
>
> On Mon, Oct 3, 2011 at 5:08 PM, Heiko Seeberger
> <heiko [dot] s [dot] [dot] [dot] [at] googlemail [dot] com> wrote:
>>> 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?
>>
>> 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
>>
>>
>

--
Martin Odersky
Prof., EPFL and Chairman, Typesafe
PSED, 1015 Lausanne, Switzerland
Tel. EPFL: +41 21 693 6863
Tel. Typesafe: +41 21 691 4967




--
Sébastien

Re: Adding ??? to Predef?

Hello,

Just add my 2 cents... This really a feature I would love to have, and
love to use.

But honestly guys, what's the point of defining on operator for this ?
what's the advantage of using an operator instead of a named
function ?
Expect making Sébastien making less effort on his keyboard (which is a
totally subjective point) ... I really don't get the point, someone
can en-light me ?

Objectively, it's just certain that this will make newcomer drive
nuts, it's impossible to "google" for an operator and it's not AT ALL
self-explanatory.

On Oct 5, 11:30 am, Sébastien Bocq wrote:
> It is not too difficult to guess from the context that ??? means that the
> implementation is missing.

Come on! tell me your kidding please...

So it's easy to give you lot of advantage about NOT using an operator,
but can someone give me some advantage of using one (in this specific
context of course) ?

Thanks,

--
Alois Cochard
http://www.twitter.com/aloiscochard
http://aloiscochard.blogspot.com

Re: Re: Adding ??? to Predef?

body p { margin-bottom: 0cm; margin-top: 0pt; }

+1.

for me '???' "sounds" like "wtf?".

I think an 'error("TODO")' is clearer. Especially for newcomers.


Alois Cochard wrote:
36f500c3-3e24-4d69-945c-abbd5c3dba0b [at] j10g2000vbb [dot] googlegroups [dot] com" type="cite">
Hello,

Just add my 2 cents... This really a feature I would love to have, and
love to use.

But honestly guys, what's the point of defining on operator for this ?
what's the advantage of using an operator instead of a named
function ?
Expect making Sébastien making less effort on his keyboard (which is a
totally subjective point) ... I really don't get the point, someone
can en-light me ?

Objectively, it's just certain that this will make newcomer drive
nuts, it's impossible to "google" for an operator and it's not AT ALL
self-explanatory.

On Oct 5, 11:30 am, Sébastien Bocq sebastien [dot] b [dot]  [dot]  [dot]  [at] gmail [dot] com (<sebastien [dot] b [dot]  [dot]  [dot]  [at] gmail [dot] com>) wrote:
It is not too difficult to guess from the context that ??? means that the
implementation is missing.
Come on! tell me your kidding please...

So it's easy to give you lot of advantage about NOT using an operator,
but can someone give me some advantage of using one (in this specific
context of course) ?

Thanks,

--
Alois Cochard
http://www.twitter.com/aloiscochard
http://aloiscochard.blogspot.com

Re: Re: Adding ??? to Predef?

I think the "newcomers" argument is not relevant. I'm a newcomer when it comes to nuclear physics and I don't expect to understand a paper about it without learning the notation used by nuclear physicists. The same goes for music, mathematics...


Le 05/10/2011 15:17, Ittay Dror a écrit :
4E8C58E4 [dot] 8010007 [at] gmail [dot] com" type="cite"> body p { margin-bottom: 0cm; margin-top: 0pt; }

+1.

for me '???' "sounds" like "wtf?".

I think an 'error("TODO")' is clearer. Especially for newcomers.


Alois Cochard wrote:
36f500c3-3e24-4d69-945c-abbd5c3dba0b [at] j10g2000vbb [dot] googlegroups [dot] com" type="cite">
Hello,

Just add my 2 cents... This really a feature I would love to have, and
love to use.

But honestly guys, what's the point of defining on operator for this ?
what's the advantage of using an operator instead of a named
function ?
Expect making Sébastien making less effort on his keyboard (which is a
totally subjective point) ... I really don't get the point, someone
can en-light me ?

Objectively, it's just certain that this will make newcomer drive
nuts, it's impossible to "google" for an operator and it's not AT ALL
self-explanatory.

On Oct 5, 11:30 am, Sébastien Bocq sebastien [dot] b [dot]  [dot]  [dot]  [at] gmail [dot] com" rel="nofollow"><sebastien [dot] b [dot]  [dot]  [dot]  [at] gmail [dot] com> wrote:
It is not too difficult to guess from the context that ??? means that the
implementation is missing.
Come on! tell me your kidding please...

So it's easy to give you lot of advantage about NOT using an operator,
but can someone give me some advantage of using one (in this specific
context of course) ?

Thanks,

--
Alois Cochard
http://www.twitter.com/aloiscochard
http://aloiscochard.blogspot.com


-- 
Sylvain HENRY
PhD Student INRIA/LaBRI RunTime Team
Tel: +33 (0)6-70-94-86-76
http://hsyl20.fr

Re: Re: Adding ??? to Predef?

On Thu, Oct 6, 2011 at 10:09 AM, Sylvain HENRY wrote:
> I think the "newcomers" argument is not relevant. I'm a newcomer when it
> comes to nuclear physics and I don't expect to understand a paper about it
> without learning the notation used by nuclear physicists. The same goes for
> music, mathematics...

I believe we want Scala to be more approachable than nuclear physics.

Best,
Ismael

Re: Re: Adding ??? to Predef?

+1
On Oct 6, 2011, at 12:22, Ismael Juma wrote:

> On Thu, Oct 6, 2011 at 10:09 AM, Sylvain HENRY wrote:
>> I think the "newcomers" argument is not relevant. I'm a newcomer when it
>> comes to nuclear physics and I don't expect to understand a paper about it
>> without learning the notation used by nuclear physicists. The same goes for
>> music, mathematics...
>
> I believe we want Scala to be more approachable than nuclear physics.
>
> Best,
> Ismael

Re: Re: Adding ??? to Predef?

FWIW, particularly in a bigger project perhaps between teams, I sometimes deliver a partially implemented interface, with the rest to follow in a later drop - so for that reason providing a message in a standard way could be handy (but it's not a massive deal). So there's no really easy/neat way to handle an arg-less function with an overloaded variant without having to use empty parens on the no-arg version?

Re: Re: Adding ??? to Predef?

I think we have certain people on the mailing list which won't agree with that... :-)

Apart from that I really prefer ???, because it is already widely used. There is a reason why multiple projects without any connection decided to go with ??? and not something else.

If people think there is too much predefined by default, then they should start with throwing out any2stringadd and the lossy numeric conversions first.

Re: Re: Adding ??? to Predef?



On 6 October 2011 10:35, Simon Ochsenreither <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
 
If people think there is too much predefined by default, then they should start with throwing out any2stringadd and the lossy numeric conversions first.

This would make me very happy - these are the sorts of things things I'd personally prefer to have moved out from predef into a 'java-compat-mode-predef' package object that also imports the java collection bridges.
Matthew

--
Dr Matthew PocockIntegrative Bioinformatics Group, School of Computing Science, Newcastle Universitymailto: turingatemyhamster [at] gmail [dot] com gchat: turingatemyhamster [at] gmail [dot] commsn: matthew_pocock [at] yahoo [dot] co [dot] uk irc.freenode.net: drdozertel: (0191) 2566550mob: +447535664143

Re: Re: Adding ??? to Predef?

Hi,

I'm also intrigued about why the existing `sys.error("todo")` is not an option.

Regards,
Germán

On Wed, Oct 5, 2011 at 11:17 AM, Ittay Dror <ittay [dot] dror [at] gmail [dot] com> wrote:

+1.

for me '???' "sounds" like "wtf?".

I think an 'error("TODO")' is clearer. Especially for newcomers.


Alois Cochard wrote:
Hello,

Just add my 2 cents... This really a feature I would love to have, and
love to use.

But honestly guys, what's the point of defining on operator for this ?
what's the advantage of using an operator instead of a named
function ?
Expect making Sébastien making less effort on his keyboard (which is a
totally subjective point) ... I really don't get the point, someone
can en-light me ?

Objectively, it's just certain that this will make newcomer drive
nuts, it's impossible to "google" for an operator and it's not AT ALL
self-explanatory.

On Oct 5, 11:30 am, Sébastien Bocq sebastien [dot] b [dot]  [dot]  [dot]  [at] gmail [dot] com (<sebastien [dot] b [dot]  [dot]  [dot]  [at] gmail [dot] com>) wrote:
It is not too difficult to guess from the context that ??? means that the
implementation is missing.
Come on! tell me your kidding please...

So it's easy to give you lot of advantage about NOT using an operator,
but can someone give me some advantage of using one (in this specific
context of course) ?

Thanks,

--
Alois Cochard
http://www.twitter.com/aloiscochard
http://aloiscochard.blogspot.com

Re: Adding ??? to Predef?

And herein lies the fundamental problem with Predef.
The Predef appropriate for a classroom is not the Predef appropriate for an industrial setting is not the Predef appropriate for high-performance numerical computing is not the Predef appropriate for...
On Tue, Oct 4, 2011 at 3:02 AM, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:
My main point is that I want to use it as an effective teaching tool.

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

Re: Adding ??? to Predef?

On Tue, Oct 4, 2011 at 9:42 PM, Jorge Ortiz wrote:
> And herein lies the fundamental problem with Predef.
> The Predef appropriate for a classroom is not the Predef appropriate for an
> industrial setting is not the Predef appropriate for high-performance
> numerical computing is not the Predef appropriate for...

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.

Re: Adding ??? to Predef?

Hi Martin,

On 4 October 2011 20:47, martin odersky <martin [dot] odersky [at] epfl [dot] ch> wrote:

Sure. So we need a compromise. But there's value in standardizing,
too.

I agree, but that doesn't necessarily mean a single, monolithic predef. It already gets in the way with things like the StringAdd pimp and + operator - makes sense form a Java compatibility point of view, but has lead to so many compilation and/or run-time errors for me. The proposal to add ??? to predef is in itself not that objectionable to me. It's more that it's the straw that breaks the camel's back.   
My reaction is the usual: Make simple things easy and hard things
possible.

This is a philosophy that I do agree with, but at some point it's necessary to recognise that one size does not fit all, and that the base-level environment needed for teaching, rapid prototyping, developing stable code (and perhaps other development profiles) are all different and are not monotonic extensions of one-another. The current monolithic predef doesn't support us in recognising this. I see this discussion as intimately related to the idea of modularising the core library.
As a straw-man example, the portions of the predef that makes scala behave a bit like Java (e.g. + coercion to string), together with the implicits for translating between java and scala collections could be bundled up into a 'java interoperability' package object. Those coming from Java would be encouraged to say: import scala.javaInterop, and as they become more confident, they will learn to use the specific imports for the specific interop they require.
I guess the question I'm posing is this: what portions of predef frame scala as a language, and what portions of it are there because most people will probably want it, so by putting it in predef we avoid them typing the same import into each file? For example, is the collections aliasing a convenience to let people not explicitly import the immutable collections or is it part of setting up the language to preferentially support immutable collections? If it's just a convenience, then I'd be for loosing it from a predef-lite and shifting it into a scala.collections package object. If it's part of what makes scala feel like scala to the coder, then it should stay in predef.

Re: Adding ??? to Predef?

I agree with Jorge: "I want to use it as an effective teaching tool"
seems at odds with the fact that '???' is incompatible with search
engines. Not everyone learns in a classroom.

For the general functionality, I vote for 'undefined'. It's boring
and doesn't visually stand out as much (though I've never had trouble
with it in Haskell), but it's general, its meaning is clear, and it's
searchable. 'TODO' is slightly more exciting and stands out better,
but it carries extra connotation that may be inappropriate for some
use cases (something can be undefined without actually requiring
additional action). If that extra connotation is desired, then my
vote is for 'TODO' with some kind of compiler support to emit
warnings.

Best,
Jason

On Oct 4, 3:02 am, martin odersky wrote:
> My main point is that I want to use it as an effective teaching tool.
>
> 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
>
> On Tue, Oct 4, 2011 at 4:12 AM, Archontophoenix Quar
>
>
>
>
>
>
>
>
>
> wrote:
> > People who don't understand ??? aren't reading enough comics.
>
> > A
>
> > On Mon, Oct 3, 2011 at 5:08 PM, Heiko Seeberger
> > wrote:
> >>> 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?
>
> >> 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
>
> --
> Martin Odersky
> Prof., EPFL and Chairman, Typesafe
> PSED, 1015 Lausanne, Switzerland
> Tel. EPFL: +41 21 693 6863
> Tel. Typesafe: +41 21 691 4967

Re: Re: Adding ??? to Predef?

I agree, actually it should be undefined() since the function has side-effects.
Lieven

On Tue, Oct 4, 2011 at 5:18 PM, jfager <jfager [at] gmail [dot] com> wrote:
I agree with Jorge:  "I want to use it as an effective teaching tool"
seems at odds with the fact that '???' is incompatible with search
engines.  Not everyone learns in a classroom.

For the general functionality, I vote for 'undefined'.  It's boring
and doesn't visually stand out as much (though I've never had trouble
with it in Haskell), but it's general, its meaning is clear, and it's
searchable.  'TODO' is slightly more exciting and stands out better,
but it carries extra connotation that may be inappropriate for some
use cases (something can be undefined without actually requiring
additional action).  If that extra connotation is desired, then my
vote is for 'TODO' with some kind of compiler support to emit
warnings.

Best,
Jason




On Oct 4, 3:02 am, martin odersky <martin [dot] oder [dot] [dot] [dot] [at] epfl [dot] ch> wrote:
> My main point is that I want to use it as an effective teaching tool.
>
> 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
>
> On Tue, Oct 4, 2011 at 4:12 AM, Archontophoenix Quar
>
>
>
>
>
>
>
>
>
> <archonq [dot] [dot] [dot] [at] gmail [dot] com> wrote:
> > People who don't understand ??? aren't reading enough comics.
>
> > A
>
> > On Mon, Oct 3, 2011 at 5:08 PM, Heiko Seeberger
> > <heiko [dot] seeber [dot] [dot] [dot] [at] googlemail [dot] com> wrote:
> >>> 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?
>
> >> 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
>
> --
> Martin Odersky
> Prof., EPFL and Chairman, Typesafe
> PSED, 1015 Lausanne, Switzerland
> Tel. EPFL: +41 21 693 6863
> Tel. Typesafe: +41 21 691 4967

Re: Re: Adding ??? to Predef?

Actually, it's not a side-effecting function since its result (_|_) is referentially transparent.  Slightly unintuitive, but true.  Another way of thinking about this is looking at Nil.head, which is a pure function that throws an exception.

Daniel

On Tue, Oct 4, 2011 at 10:26 AM, Lieven Lemiengre <lieven [dot] lemiengre [at] gmail [dot] com> wrote:
I agree, actually it should be undefined() since the function has side-effects.
Lieven

On Tue, Oct 4, 2011 at 5:18 PM, jfager <jfager [at] gmail [dot] com> wrote:
I agree with Jorge:  "I want to use it as an effective teaching tool"
seems at odds with the fact that '???' is incompatible with search
engines.  Not everyone learns in a classroom.

For the general functionality, I vote for 'undefined'.  It's boring
and doesn't visually stand out as much (though I've never had trouble
with it in Haskell), but it's general, its meaning is clear, and it's
searchable.  'TODO' is slightly more exciting and stands out better,
but it carries extra connotation that may be inappropriate for some
use cases (something can be undefined without actually requiring
additional action).  If that extra connotation is desired, then my
vote is for 'TODO' with some kind of compiler support to emit
warnings.

Best,
Jason




On Oct 4, 3:02 am, martin odersky <martin [dot] oder [dot] [dot] [dot] [at] epfl [dot] ch> wrote:
> My main point is that I want to use it as an effective teaching tool.
>
> 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
>
> On Tue, Oct 4, 2011 at 4:12 AM, Archontophoenix Quar
>
>
>
>
>
>
>
>
>
> <archonq [dot] [dot] [dot] [at] gmail [dot] com> wrote:
> > People who don't understand ??? aren't reading enough comics.
>
> > A
>
> > On Mon, Oct 3, 2011 at 5:08 PM, Heiko Seeberger
> > <heiko [dot] seeber [dot] [dot] [dot] [at] googlemail [dot] com> wrote:
> >>> 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?
>
> >> 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
>
> --
> Martin Odersky
> Prof., EPFL and Chairman, Typesafe
> PSED, 1015 Lausanne, Switzerland
> Tel. EPFL: +41 21 693 6863
> Tel. Typesafe: +41 21 691 4967


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