[FYI] Java vs Squeak/Smalltalk, with <CSOTD> included!

jescoto at objective.com.br jescoto at objective.com.br
Wed Jan 16 13:46:45 UTC 2002


I tried it on Object Studio 6.1 and it answered  #(1)...
This on squeak wasn't the same.


| a |
a := #(1).
a at: 1 put: 2.
( 'An array with... what? ', #(1) printString) out.

PS: Object Studio doesn't have Transcript, but there is that
ObjectClass>>out which does the same.



                                                                                                                                       
                    goran.hultgren at bluefish.se                                                                                         
                    Sent by:                                 To:     squeak-dev at lists.squeakfoundation.org                             
                    squeak-dev-admin at lists.squeakfoun        cc:                                                                       
                    dation.org                               Subject:     Re: [FYI] Java vs Squeak/Smalltalk, with <CSOTD> included!   
                                                                                                                                       
                                                                                                                                       
                    16/01/2002 09:06                                                                                                   
                    Please respond to squeak-dev                                                                                       
                                                                                                                                       
                                                                                                                                       



(snip)

<CSOTD>
"This one is a newbie trap I fell into myself the other day.
Before you do-it, what do you think it will say in the Transcript?"

| a |
a _ #(1).
a at: 1 put: 2.
Transcript show: 'An array with... what? ', #(1) printString;cr.

"Learn these two things:

1. A literal is not a constant. It is just sugar for creating an object.
2. Two equal literals (I guess) in the same method will be compiled to
refer to the same object!

PS. This almost drove me insane the other day... DS"
</CSOTD>








More information about the Squeak-dev mailing list