[squeak-dev] Syntactic sugar for Transcript show:

mail at jaromir.net mail at jaromir.net
Fri Dec 10 20:24:57 UTC 2021


Hi Tobias, all

I just re-read my reply and was afraid it might be interpreted as rude. >>... it's by no means "important"<< of course referred to *my suggestion* ;) Apologies!

> Anyway, I hear your objection and understand it's by no means "important"; it just seemed to me (1) convenient and (2) as a beginner I struggled with the Transcript concept [...]

I just came across three ancient methods in Object I've never noticed before: logEntry, logExecution and logExit; would it be a bad idea to add a fourth one e.g. logMe printing the receiver to the Transcript?
existing:
logEntry
	Transcript show: 'Entered ', thisContext sender printString; cr.

proposed:
logMe
	Transcript show: 'Logged ', self printString; cr.

I also realized my previous examples were really counterproductive - Transcript is indeed not a primary tool for displaying *results* of expressions/methods but rather for observing their *side-effects*! More suitable example could perhaps be:

#(A B C) shuffled do: [:each | [('player ', each, ' started') logMe] fork]

Thanks,
~~~
^[^    Jaromir

Sent from Squeak Inbox Talk

On 2021-12-06T21:19:51+01:00, das.linux at gmx.de wrote:

> Hi Jaromir
> 
> 
> > On 6. Dec 2021, at 20:16, mail at jaromir.net wrote:
> > 
> > Hi all,
> > 
> > I'd like to propose two little unary helper methods to facilitate printing to the Transcript window. It would allow
> > 
> > #(1 2 3) transcriptShowln
> > 
> > in addition to
> > 
> > Transcript cr; show: #(1 2 3)
> > 
> > You could sprinkle such calls into existing code without having to change too much punctuation (like statements or parentheses etc.) just like calling #inspect or #explore.
> > 
> > Similar implementation is present in Cuis or Pharo and a simple "print" command is usual in most languages (except a few like Java).
> > 
> > As for naming: I incline towards using the verb show rather than print because Transcript print: doesn't show the output until you flush it while Transcript show: displays the output immediately. Adding 'transcript' to the name allows for easy spotting of these calls in the code; plain #print or #show could collide with namesake methods.
> > 
> > Object>>transcriptShowln
> > 
> > 	Transcript cr; show: self
> > 
> > 
> > Object>>transcriptShow
> > 
> > 	Transcript show: self
> > 
> > If there are no objections I'll send a changeset to the Inbox.
> 
> I think 
> 
> 	Transcript showln: anObject 
> 
> is sufficient.
> 
> If not, you always have Object>>printOn:
> 
> Best regards
> 	-Tobias
> 
> 


More information about the Squeak-dev mailing list