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

Adding ??? to Predef?

103 replies
Jorge Ortiz
Joined: 2008-12-16,
User offline. Last seen 29 weeks 3 days ago.
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 }


Ismael Juma 2
Joined: 2011-01-22,
User offline. Last seen 42 years 45 weeks ago.
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

hseeberger
Joined: 2008-12-27,
User offline. Last seen 1 year 25 weeks ago.
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

Archontophoenix Quar
Joined: 2011-04-01,
User offline. Last seen 42 years 45 weeks ago.
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
>
>

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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

Matthew Pocock 3
Joined: 2010-07-30,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
I like the idea of ??? for things that aren't implemented yet. I don't like the idea of further bloating predef, and I definitely think that if it is added, it should be supported by scalac switches so that when they are thrown, any remaining ??? breaks compilation.
Can we possible to put ??? (and any related operators) into their own DSL object that people can explicitly import?
Matthew

On 4 October 2011 08:02, 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

d_m
Joined: 2010-11-11,
User offline. Last seen 35 weeks 2 days ago.
Re: Adding ??? to Predef?

On Tue, Oct 04, 2011 at 09:02:58AM +0200, martin odersky wrote:
> 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.

The ??? isn't the only case where this is a problem. There are lots of
other places in my Scala code where I have to do imports or annotations
which "destroy the flow". Some examples I can think of:

1. import scala.math.Numeric.ExtraImplicits._

Numeric is pretty unusable unless you can use infix operators. The
only ways to accomplish this stills adds import boilerplate to every
file or (worse) every use of a numeric type parameter.

2. import Predef.{any2stringadd => _}

When using my own Numeric I have to disable any2stringadd, this is
another per-file piece of boilerplate.

3. @specialized T:Numeric

When using a specialized Numeric type class, you have you annotate
every type parameter with specialized or else you lose the speed
benefits of specialization. This is *really* ugly!

#1 is not so bad, until you consider that you probably also had to
import scala.math.Numeric itself, so that's two lines. #3 is worse
because it's such a weird-looking import and most people don't have any
idea what it's doing.

#3 is the worst. Given that you need to specialized throughout your
critical path to see performance benefits, this ensures that all your
code becomes clunky and harder to read. Also it's easy to leave this
off by accident.

I am not arguing against ??? per se, but given that other stuff in
Predef is giving me headaches (see 2) I guess I resent the fact that
we're willing to make Predef bigger to prevent having to do a single
import. Other Scala patterns require much more onerous boiler-plate,
with no reprieve in sight.

Jason Fager
Joined: 2011-05-06,
User offline. Last seen 42 years 45 weeks ago.
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

LLemiengre
Joined: 2008-08-19,
User offline. Last seen 4 years 4 weeks ago.
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

daniel
Joined: 2008-08-20,
User offline. Last seen 44 weeks 14 hours ago.
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


adriaanm
Joined: 2010-02-08,
User offline. Last seen 31 weeks 4 days ago.
Re: Re: Adding ??? to Predef?


On Tue, Oct 4, 2011 at 5:49 PM, Daniel Spiewak <djspiewak [at] gmail [dot] com> wrote:
a pure function that throws an exception
... is not a pure function -- at least not for the definition of "pure" that I'm used tofrom the same book of definitions, throwing an exception is considered an effect (the throws clause in Java is actually part of a lightweight type and effect system)
the non-terminating term _|_ is actually from the "impure fragment" of Haskell, and it can also be tracked by an effect system, but lets not go there (tangentially, for the logic corresponding to Haskell's type system to be consistent, you need to disregard bottom [http://www.haskell.org/pipermail/haskell-cafe/2007-October/033580.html], so it certainly has the bitter flavour of impurity to it)
daniel
Joined: 2008-08-20,
User offline. Last seen 44 weeks 14 hours ago.
Re: Re: Adding ??? to Predef?

a pure function that throws an exception
... is not a pure function -- at least not for the definition of "pure" that I'm used tofrom the same book of definitions, throwing an exception is considered an effect (the throws clause in Java is actually part of a lightweight type and effect system)
the non-terminating term _|_ is actually from the "impure fragment" of Haskell, and it can also be tracked by an effect system, but lets not go there (tangentially, for the logic corresponding to Haskell's type system to be consistent, you need to disregard bottom [http://www.haskell.org/pipermail/haskell-cafe/2007-October/033580.html], so it certainly has the bitter flavour of impurity to it)

Oooh, meta-theory!

Bottom's inconsistency is a problem more general than simply Haskell.  We can view _|_ as the value which corresponds to the type, (forall a . a).  By the Curry-Howard isomorphism (in its binary logical incarnation), this is the same as saying that we have a proof for every proposition.  So, any language which has _|_ must have an inconsistent logic according to a strict interpretation of CH.  I've always found this just a little annoying, which is why I carefully specified "binary logical incarnation".  However, we're drilling way down into the weeds here!

The larger question is whether or not _|_ represents an impure fragment.  I'm still strongly of the opinion that the answer here is "no".  While it is certainly possible to encode exceptions as effects, it is not necessary.  For example, a monadic encoding of exceptions would be pure and trivially isomorphic to checked exceptions in Java (though with a lot more control over the composition).  This alone implies that _|_ at least has a trivial pure encoding, which suggests that _|_ itself may be pure.

Some of this depends on your perspective.  Referential transparency is of course the defining property of purity, and referential transparency does have a very strong definition.  _|_ on the other hand is a little weird, since it is a value which corresponds to forall a . a, which is to say it is not a value at all.  This would seem to imply that we cannot reason about it directly in terms of referential transparency since the definition requires a value to even make sense.

I think in order to really have this argument properly, we would need to split exceptions from non-termination.  We're overloading _|_ too much, and that's muddying the waters.  I tend to think of exceptions in terms of their monadic encoding, by which definition throw becomes a pure operation as it is referentially transparent (it always produces the same result given the same exception).  I tend to think of _|_ as the value corresponding to non-termination, which is to say not a value at all and thus not pure, but also not impure.  Turing Compute systems really suck.

Anyway, I think we've largely derailed this thread.  Sorry everyone!

Daniel
Jorge Ortiz
Joined: 2008-12-16,
User offline. Last seen 29 weeks 3 days ago.
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

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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.

Matthew Pocock 3
Joined: 2010-07-30,
User offline. Last seen 42 years 45 weeks ago.
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.

Joni Freeman 3
Joined: 2011-10-05,
User offline. Last seen 42 years 45 weeks ago.
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

Sebastien Bocq
Joined: 2008-12-18,
User offline. Last seen 42 years 45 weeks ago.
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
alois.cochard
Joined: 2010-03-19,
User offline. Last seen 34 weeks 3 hours ago.
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

Ittay Dror 2
Joined: 2010-05-05,
User offline. Last seen 42 years 45 weeks ago.
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
Jeff Olson
Joined: 2011-06-29,
User offline. Last seen 42 years 45 weeks ago.
Re: Adding ??? to Predef?
I noticed that there already exists a NotDefinedError in the scala namespace. It is, however, deprecated. I don't know what the history of this class is or why it is deprecated, but it seems like a perfect candidate for the exception thrown by ???. That way we'd only have to undeprecate an already existing name instead of adding a new one. Just a thought.

-Jeff

gerferra
Joined: 2009-08-26,
User offline. Last seen 1 year 38 weeks ago.
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

Sylvain HENRY
Joined: 2009-05-28,
User offline. Last seen 42 years 45 weeks ago.
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
Ismael Juma 2
Joined: 2011-01-22,
User offline. Last seen 42 years 45 weeks ago.
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

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
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.
Matthew Pocock 3
Joined: 2010-07-30,
User offline. Last seen 42 years 45 weeks ago.
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
DaveScala
Joined: 2011-03-18,
User offline. Last seen 1 year 21 weeks ago.
Re: Adding ??? to Predef?

I agree

An optional message is handy for tagging the location ??? (like ???
("true branch")) or writing an implementation assignment.
and you don't have to use it.

scala> class NotYetImplementedException(msg: String) extends
Exception(msg)
defined class NotYetImplementedException

scala> def ???(implicit msg : String = "") : Nothing = throw new
NotYetImplementedException(msg)
$qmark$qmark$qmark: (implicit msg: String)Nothing

scala> ???
NotYetImplementedException:
at .$qmark$qmark$qmark(:8)
at .(:10)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala.tools.nsc.interpreter.IMain
$ReadEvalPrint.call(IMain.scala:704)

at scala.tools.nsc.interpreter.IMain$Request$$anonfun
$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV
$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:722)

scala> def m(test: Boolean) = {
| if(test) ???("Implement true")
| else ???("Implement false")
| }
m: (test: Boolean)Nothing

scala> m(true)
NotYetImplementedException: Implement true
at .$qmark$qmark$qmark(:8)
at .m(:10)
at .(:11)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala.tools.nsc.interpreter.IMain
$ReadEvalPrint.call(IMain.scala:704)

at scala.tools.nsc.interpreter.IMain$Request$$anonfun
$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV
$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:722)

scala> m(false)
NotYetImplementedException: Implement false
at .$qmark$qmark$qmark(:8)
at .m(:11)
at .(:11)
at .()
at .(:11)
at .()
at $print()
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
43)
at java.lang.reflect.Method.invoke(Method.java:601)
at scala.tools.nsc.interpreter.IMain
$ReadEvalPrint.call(IMain.scala:704)

at scala.tools.nsc.interpreter.IMain$Request$$anonfun
$14.apply(IMain.scala:920)
at scala.tools.nsc.interpreter.Line$$anonfun$1.apply$mcV
$sp(Line.scala:43)
at scala.tools.nsc.io.package$$anon$2.run(package.scala:25)
at java.lang.Thread.run(Thread.java:722)

On 1 okt, 20:40, Simon Ochsenreither
wrote:
> 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.

Adam Jorgensen
Joined: 2011-04-17,
User offline. Last seen 42 years 45 weeks ago.
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 }



odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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,

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Adding ??? to Predef?
What about allowing an optional exception message?

Would be quite handy for teaching imho ...
LouisB
Joined: 2009-11-25,
User offline. Last seen 2 years 46 weeks ago.
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.

Jon Steelman
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
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.


odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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?

Som Snytt
Joined: 2011-09-19,
User offline. Last seen 42 years 45 weeks ago.
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).


Chris Twiner
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
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
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
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.

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
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
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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

Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
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
etorreborre 2
Joined: 2011-02-23,
User offline. Last seen 42 years 45 weeks ago.
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.
Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
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.


etorreborre 2
Joined: 2011-02-23,
User offline. Last seen 42 years 45 weeks ago.
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.

loverdos
Joined: 2008-11-18,
User offline. Last seen 2 years 27 weeks ago.
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

LouisB
Joined: 2009-11-25,
User offline. Last seen 2 years 46 weeks ago.
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?
fanf
Joined: 2009-03-17,
User offline. Last seen 2 years 30 weeks ago.
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
odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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.

Patrik Andersson
Joined: 2009-11-16,
User offline. Last seen 42 years 45 weeks ago.
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.

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
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.

Patrik Andersson
Joined: 2009-11-16,
User offline. Last seen 42 years 45 weeks ago.
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.

DaveScala
Joined: 2011-03-18,
User offline. Last seen 1 year 21 weeks ago.
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.

Archontophoenix Quar
Joined: 2011-04-01,
User offline. Last seen 42 years 45 weeks ago.
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.
>
>
>

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