I have a question about the right way to call String.new() constructor.
The book says on page 235 that it should be like String.new(length).
Does it translate to following vm code
call String.new 1
And does '1' above represent the 'this' ?
There is no 'this' involved in the call to a constructor. The '1' is the number of parameters
Creating the string constant is the same as creating any other String object.
is functionally equivalent to
let str = String.new(3);
The confusing bit is that because the compiler requires that appendChar() return the String that was passed to it, the compiler can shortcut popping the return value and pushing 'str' for the next call when it is creating a String constant.