I've decided to give gnu-smalltalk another chance to convince me. ;)
I'm using Canol Gökel's "Computer Programming using GNU Smalltalk" to teach myself the language.
My solution to the very first exercise in the book involves sending repetitive printLn messages to strings. It got the job done, but it also prints out the 'single quotes' along with the string. NOT what I was expecting.
However, when I used Transcript show:'blah';cr.
the output was correct (without the 'single quotes').
What's going on with printLn? I'm probably not seeing the obvious, so I'm glad that this mailing list exist and that there's still some gnu-smalltalk enthusiast lurking here. TIA ...
the first line is the side-effect of execution (displaying the
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
irb(main):001:0> puts 'hello'
`puts 'hello'` prints the string, then evaluates to nil
`'hello'` has no side-effect - it simply evaluates to itself
> 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
> st> Transcript show: 'hello' ; cr
Yes! That's the output I'm getting.
I've work quite a lot with various LISP REPLs, so I get it about the "double" output while working in the REPL.
However, I'm getting the same behaviour executing the source code file from the CLI.
Not sure whether this helps but there also exists a #displayNl message.
GNU Smalltalk ready
st> 'hello' printNl
st> 'hello' displayNl
st> Smalltalk version
'GNU Smalltalk version 3.2.91'
Note that for #printNl the output has '' quotes and for #displayNl it does not.
If you check the source code in Object.st (/usr/share/smalltalk/kernel/Object.st)
"Print a represention of the receiver, then put a new line on
the Transcript (stdout the GUI is not active). For most objects this
is simply its #printNl representation, but for strings and
characters, superfluous dollars or extra pair of quotes are stripped."
> On Sun, 18 Apr 2021 19:04:10 -0400
> bill-auger <[hidden email]> wrote:
>> 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
>> st> Transcript show: 'hello' ; cr
> Yes! That's the output I'm getting.
> I've work quite a lot with various LISP REPLs, so I get it about the "double"
> output while working in the REPL.
> However, I'm getting the same behaviour executing the source code file from the
> On 18/04/21 23:47, Duke Normandin wrote:
> > What's going on with printLn?
Thanks! Using ``displayNl'' emits the correct output to STDOUT.
It's sad and too bad that the only comprehensive gnu-smalltalk tutorial that I've been able to stumble on doesn't mention that screen output message. The existence of this mailing list is therefore a God-send to anyone learning/re-learning gnu-smalltalk.
> ----- Op 19 apr 2021 om 13:47 schreef Duke Normandin
> [hidden email]:
> > Thanks! Using ``displayNl'' emits the correct output to STDOUT.
> Also thanks for reporting the free book on GNU smalltalk, I wasn't
> aware of it:
> http://stephane.ducasse.free.fr/FreeBooks.html >
> mentions this free e-book on GNU smalltalk.
No problem! I'm annotating the pdf to bring some items up-to-date as I work my way through the book. Good way to learn!
I just discovered 2 things:
1. always terminated a line of coding with a period/full-stop
2. never put a period/full-stop after a [ ..... ]
At least I think that is correct, because doing so fixed 2 scripts.
i suppose that you are seeing an error with a period/full-stop
after a method definition - that syntax is something of a
special form for gnu-smalltalk - most smalltalk dialects do not
use square-brackets to enclose class and method definitions