help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: printNl question


From: bill-auger
Subject: Re: printNl question
Date: Sun, 18 Apr 2021 19:04:10 -0400

rather than casual explanations of the problem, it is usually
more helpful to show the exact commands and output - for
example, is this what you are seeing?

  $ gst

  st> 'hello' printNl
  'hello'
  'hello'

  st> Transcript show: 'hello' ; cr
  hello
  Transcript

the first line is the side-effect of execution (displaying the
string)

the second line is the evaluation of the message chain
(the objects: 'hello' and Transcript) - think of those as the
return result of function evaluation, in other languages - in
both of those cases, the message chain evaluates to the receiver

this is a common idiom for REPLs - it is a little more evident in
ruby

  $ irb

  irb(main):001:0> puts 'hello'
  hello
  => nil

  irb(main):002:0> 'hello'
  => "hello"

`puts 'hello'` prints the string, then evaluates to nil
`'hello'` has no side-effect - it simply evaluates to itself



reply via email to

[Prev in Thread] Current Thread [Next in Thread]