<br><div><span class="gmail_quote">On 3/31/07, <b class="gmail_sendername">Young-Jin Lee</b> <<a href="mailto:firstname.lastname@example.org">email@example.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I am a newbie trying to learn Squeak.<br>The squeak book and tutorials says that I need to define a local<br>variable using a pipe like below:<br><br>| someMuppet |<br>someMuppet := Muppet new.<br>someMuppet name: 'Elmo'.
<br>someMuppet greet.<br><br>But when I tried the same code without defining a local variable shown<br>below, I got the expected results, which makes me wonder when I should<br>define a local variable.<br><br>anotherMuppet := Muppet new.
<br>anotherMuppet name: 'Gookie Monster'.<br>anotherMuppet greet.<br><br>My guess is that I need not define a local variable if my code is<br>being executed within a Workspace because all variables such as<br>anotherMuppet will have "Workspace" scope.
</blockquote><div><br>On the surface this is correct, but the language has no explicit notion of "Workspace" scope. If you take a look at the comment in the Class Workspace you can get a sense of how Workspaces end up with this and other interesting/useful behavior as a result of having the ide written in the language. Smalltalk/Squeak is more than the grammar, it is an environment - the whole is greater than the sum of the parts. Often we do type source code into text editors as with other languages but eToys, Connectors, Croquet and other tools offer alternatives. Depending on what language background you're coming from this may be a subtle but very liberating observation. You may not need to dig into this but if it seems interesting to you, as you use different code editing tools in the environment, try your code above or evaluate the word self.
<br><br>Enjoy!<br><br>Laurence<br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Can anyone please explain in more detail about variable scopes?
</blockquote><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Thanks in advance.<br><br>Young-Jin Lee<br>_______________________________________________
<br>Squeakland mailing list<br><a href="mailto:Squeakland@squeakland.org">Squeakland@squeakland.org</a><br><a href="http://squeakland.org/mailman/listinfo/squeakland">http://squeakland.org/mailman/listinfo/squeakland</a><br>