Top-level functions

107 views
Skip to first unread message

Eugene Burmako

unread,
Dec 9, 2012, 8:24:14 AM12/9/12
to <scala-internals@googlegroups.com>
Why not?

Jason Zaugg

unread,
Dec 9, 2012, 11:14:43 AM12/9/12
to scala-i...@googlegroups.com
On Sun, Dec 9, 2012 at 2:24 PM, Eugene Burmako <eugene....@epfl.ch> wrote:
Why not?

I would suggest overloading, and separate compilation.

Enforcing that all the top-level stuff is in one file in the package object means you don't have to worry about how to merge top-level functions from previous runs and different units in the current run into one scope / JVM class.

-jason

martin odersky

unread,
Dec 9, 2012, 11:21:26 AM12/9/12
to scala-internals
Mostly, packaging. Where would you put them? Each in a classfile of its own? What would the name of the classfile be? 
 - Martin


On Sun, Dec 9, 2012 at 2:24 PM, Eugene Burmako <eugene....@epfl.ch> wrote:
Why not?



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

Patrik Andersson

unread,
Dec 9, 2012, 1:52:34 PM12/9/12
to scala-i...@googlegroups.com, scala-internals
They would reside in a "secret" package object!

Sent from my iPad

Paul Phillips

unread,
Dec 9, 2012, 2:15:50 PM12/9/12
to scala-i...@googlegroups.com


On Sun, Dec 9, 2012 at 10:52 AM, Patrik Andersson <pande...@gmail.com> wrote:
They would reside in a "secret" package object!

The "secret synthesized package object" might also have other applications.

  //  java statics with nowhere to call home
  // java companion objects with nowhere to call home

Patrik Andersson

unread,
Dec 9, 2012, 3:13:44 PM12/9/12
to scala-i...@googlegroups.com, scala-i...@googlegroups.com
Most definitely!

martin odersky

unread,
Dec 10, 2012, 6:55:44 AM12/10/12
to scala-internals
What does "secret" mean? Also, it does not answer the question where the bytes would go. I fear that, once you go down that road you will end up at something like assemblies. I.e. the seemingly harmless "let's allow top-level functions" proposal has evolved into a "let's do a Scala module system" proposal. For the latter, I'd rather take a good look at JigSaw first when it's out, before deciding anything.

Cheers

 - Martin


Patrik Andersson

unread,
Dec 10, 2012, 7:53:22 AM12/10/12
to scala-i...@googlegroups.com
Secret wasn't that important. What I meant is that an anonymous package object could be synthesized (or an/ the existing one chosen). I'm not super-serious about this but I do think it could be done.

Thanks
Reply all
Reply to author
Forward
0 new messages