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

Unit unique value is (), not {}, is it ?

6 replies
fanf
Joined: 2009-03-17,
User offline. Last seen 2 years 30 weeks ago.

Hello,

I thought that Unit unique value was (), but in the specification
(section 4.2, 4.6.3), it is said that {} is.
Elsewhere, in section 6.9 "Tuples", it is said that "The empty tuple ()
is the unique value of type scala.Unit", and again in 6.11 "unit value
() is assumed", and again in 12.2.3 for the definition of Class Unit.

So, I suppose that that last chapter is right, is it ? If so, are
references to {} errors, or please could someone explain me why they are
not (I thought that {} was syntactic sugar for {()}).

Thanks !

Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: Unit unique value is (), not {}, is it ?
I would have thought that () was the Unit literal, and {} is an empty expression that evaluates as Unit.

Ken

On 7 April 2011 20:31, Francois <fanf42@gmail.com> wrote:
Hello,

I thought that Unit unique value was (), but in the specification (section 4.2, 4.6.3),  it is said that {} is.
Elsewhere, in section 6.9 "Tuples", it is said that "The empty tuple () is the unique value of type scala.Unit", and again in 6.11 "unit value () is assumed", and again in 12.2.3 for the definition of Class Unit.

So, I suppose that that last chapter is right, is it ? If so, are references to {} errors, or please could someone explain me why they are not (I thought that {} was syntactic sugar for {()}).

Thanks !


odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Unit unique value is (), not {}, is it ?


On Thu, Apr 7, 2011 at 12:31 PM, Francois <fanf42@gmail.com> wrote:
Hello,

I thought that Unit unique value was (), but in the specification (section 4.2, 4.6.3),  it is said that {} is.
Elsewhere, in section 6.9 "Tuples", it is said that "The empty tuple () is the unique value of type scala.Unit", and again in 6.11 "unit value () is assumed", and again in 12.2.3 for the definition of Class Unit.

So, I suppose that that last chapter is right, is it ? If so, are references to {} errors, or please could someone explain me why they are not (I thought that {} was syntactic sugar for {()}).

It was a oversight in the SLS. () is correct. Thanks for pointing out the error.

 -- Martin

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: Unit unique value is (), not {}, is it ?

On 4/7/11 3:31 AM, Francois wrote:
> I thought that Unit unique value was (), but in the specification
> (section 4.2, 4.6.3), it is said that {} is.

Trivia: tuples used to be denoted with {}. Parens were as big an
improvement as you might imagine.

Viktor Klang
Joined: 2008-12-17,
User offline. Last seen 1 year 27 weeks ago.
Re: Unit unique value is (), not {}, is it ?


On Thu, Apr 7, 2011 at 5:37 PM, Paul Phillips <paulp@improving.org> wrote:
On 4/7/11 3:31 AM, Francois wrote:
I thought that Unit unique value was (), but in the specification
(section 4.2, 4.6.3), it is said that {} is.

Trivia: tuples used to be denoted with {}.  Parens were as big an improvement as you might imagine.


Paul, if you want to make some extra cash you could always assemble a deck of Trivial Pursuit: Scala and sell online ;-)

--
Viktor Klang,
Director of Research and Development
Scalable Solutions

Code:   github.com/viktorklang
Follow: twitter.com/viktorklang
Read:   klangism.tumblr.com

thmuch
Joined: 2010-11-18,
User offline. Last seen 1 year 50 weeks ago.
Re: Unit unique value is (), not {}, is it ?

Am 07.04.2011 um 12:31 schrieb Francois:

> I thought that Unit unique value was (), but in the specification (section 4.2, 4.6.3), it is said that {} is.

https://lampsvn.epfl.ch/trac/scala/ticket/3704

:-)

bye, Thomas

odersky
Joined: 2008-07-29,
User offline. Last seen 45 weeks 6 days ago.
Re: Unit unique value is (), not {}, is it ?


On Thu, Apr 7, 2011 at 6:56 PM, Thomas Much <thomas@snailshell.de> wrote:
Am 07.04.2011 um 12:31 schrieb Francois:

> I thought that Unit unique value was (), but in the specification (section 4.2, 4.6.3),  it is said that {} is.

https://lampsvn.epfl.ch/trac/scala/ticket/3704

:-)

bye, Thomas

Fixed now, thanks. -- Martin


--
----------------------------------------------
Martin Odersky
Prof., EPFL and CEO, Scala Solutions
PSED, 1015 Lausanne, Switzerland


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