Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8163735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:07:47+00:00 2026-06-06T19:07:47+00:00

scala> object Test defined module Test Why is the defined object Test called ‘module’,

  • 0
scala> object Test
defined module Test

Why is the defined object Test called ‘module’, not companion object, by the scala interpreter ?

Is there a difference between module and companion object or is it just the same with two different names ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:07:49+00:00Added an answer on June 6, 2026 at 7:07 pm

    Technically, there is only one such thing, in the language specification it is mostly called ‘module’, but you also find this statement: “The object definition defines a single object (or: module) …” (Scala Language Specification)

    Furthermore, you can only speak of a companion object, when it actually accompanies something:

    “Generally, a companion module of a class is an object which has the same name as the class and is defined in the same scope and compilation unit. Conversely, the class is called the companion class of the module.” (again think: companion object = companion module)

    Being in companion state adds features to the companion class, namely visibility (e.g., the class can see the private fields of the companion module). Same scope and compilation unit means, they need to be defined in the same source file and same package.


    There is an interesting thread on LtU where Scala’s object versus module terminology is discussed. It contains also a link to a paper by Odersky and Zenger if you are intrigued; showing how they particularly looked at the ML language’s module system (OCaml being a major influence on Scala), and how they frame it as various approaches of modular composition (suggesting that module is a more generic concept; traits as mixin modules, …)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does the following module not compile on Scala 2.8.RC[1,2]? object Test { import
Given this Scala code: object test { def byval(a: Int) = println(Int) def byval(a:
Is there a way to implement a parameterized unit test with Scala ? Currently
What's the purpose of Scala object MODULE$ ? The following Scala object: object TestScalaObject
Please consider the following test program (using scala 2.9.0.1) object test { def main(args:Array[String])
It's often convenient to test things out in the Scala interpreter. However, one issue
Consider following code in Scala: object Test { class A {} class B extends
In Scala IDE I have the following code: package pkg.one object S { class
Java claims to be object oriented and typesafe, and Scala even more so. Internal
Normally if you create a Stream object, the head will be eagerly evaluated: scala>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.