I think it’s worth going over again some of what semiquaver said.
There are exactly two types of actions that occur in SC, and only these two:
- Variable assignment:
x = something
.
- A method call.
That is, (basically) every action in SC is a method call.
Every action is a method call.
If SC is doing something, then it must be happening through a method call. The ONLY exception is a simple variable assignment.
Therefore every action in SC must be understood with respect to the parts of a method call, aka “message send.”
- Method selector: A method call can be understood as sending a message to an object. The method selector is the message being sent. In
5.rand
, the message rand
is sent to the integer 5
. (There are two implicit method selectors: value
for objects and new
for classes.)
- Receiver: The object to which the message is sent. In
5.rand
, the receiver is 5
.
- Argument list: A method may optionally accept parameters, given in an argument list.
“Fill a list with 3 one’s” and “repeat the list 3 times” are both actions, and they are not variable assignments. Therefore it is impossible to do them without a method call.
Therefore there must be a receiver and a method selector involved. Apart from variable assignment, there are no exceptions in SC to this principle.
(1 ! 3)
: method selector = !
, receiver = 1
, argument = 3
. All OK.
Pseq([1], 3)
: method selector = new
(implicitly), receiver = class Pseq
, arguments = [1]
and 3
. All OK.
([1], 3)
is an argument list lacking a receiver and a method selector = nonsense.
More generally: every expression in SC that confuses you, look for the receiver, method selector and arguments. Because every operation comes down to these.
hjh