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

  • Home
  • SEARCH
  • 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 9047141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:49:56+00:00 2026-06-16T11:49:56+00:00

Background In Smalltalk, if you don’t excplicitly return anything then the message passing evaluates

  • 0

Background

In Smalltalk, if you don’t excplicitly return anything then the message passing evaluates to the receiver (or “self” in the message context).

For example, given this method:

MyClass >> myMethod
  Transcript show: 'hello'; cr.

Evaluating (doint “print-it”) this:

| myInstance |
myInstance := MyClass new.
myInstance myMethod.

If <print-it> is done to the last invocation, then the result would be the instance itself.

Questions

  • Why was this designed this way?
  • What is the idea behind it?
  • What was the philosophical background?
  • What are the practical benefits from it? Is it to facilitate method chaining?
  • 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-16T11:49:58+00:00Added an answer on June 16, 2026 at 11:49 am

    One very simple reason has not been stated yet: In the Virtual Machine, returning self is simpler and more efficient than returning any other object.

    Smalltalk byte codes implement a stack machine. That means arguments are passed by pushing them onto a stack, rather than putting them into registers. In addition to the arguments as listed in the method signature, a hidden argument is always passed, which is the receiver of the message. So even for unary methods (those without arguments) the receiver is pushed onto the stack, then the method is executed, and the receiver value on the stack is how the method knows “self”. By returning “self” if no explicit return statement is given, the VM can just leave the “self” oop on the stack, which saves at least one memory store operation. So from an efficiency and simplicity standpoint, returning “self” is the most elegant thing to do.

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

Sidebar

Related Questions

Background Something that catches every Smalltalk newbie is that add: does not return self
Background: I have a performance-critical query I'd like to run and I don't care
Background: What I need to accomplish is to remove any records in a collection
Background: We're building an application that allows our customers to supply data in a
Background: I'm using the (fantastic) Vim plugin python-mode , which includes the pep8 linter.
Background - I am using paramiko to put files on a bunch of remote
Background : I'm trying to convert some JavaScript code which uses the the Crossfilter
Background: I would like to dismiss a modalView that I have presented earlier and
Background I am working with a monad built of a stack of transformers one
Background: I was invited to an interview at a high profile company and I

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.