Hi,
I am a newbie trying to learn Squeak. The squeak book and tutorials says that I need to define a local variable using a pipe like below:
| someMuppet | someMuppet := Muppet new. someMuppet name: 'Elmo'. someMuppet greet.
But when I tried the same code without defining a local variable shown below, I got the expected results, which makes me wonder when I should define a local variable.
anotherMuppet := Muppet new. anotherMuppet name: 'Gookie Monster'. anotherMuppet greet.
My guess is that I need not define a local variable if my code is being executed within a Workspace because all variables such as anotherMuppet will have "Workspace" scope.
Can anyone please explain in more detail about variable scopes?
Thanks in advance.
Young-Jin Lee
Hi, Young-Jin Lee,
Your guess is exactly correct. Workspaces assume that any otherwise- unknown variable is intended to be a "workspace" variable.
Cheers,
-- Scott
On Mar 31, 2007, at 9:58 AM, Young-Jin Lee wrote:
Hi,
I am a newbie trying to learn Squeak. The squeak book and tutorials says that I need to define a local variable using a pipe like below:
| someMuppet | someMuppet := Muppet new. someMuppet name: 'Elmo'. someMuppet greet.
But when I tried the same code without defining a local variable shown below, I got the expected results, which makes me wonder when I should define a local variable.
anotherMuppet := Muppet new. anotherMuppet name: 'Gookie Monster'. anotherMuppet greet.
My guess is that I need not define a local variable if my code is being executed within a Workspace because all variables such as anotherMuppet will have "Workspace" scope.
Can anyone please explain in more detail about variable scopes?
Thanks in advance.
Young-Jin Lee _______________________________________________ Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
On 3/31/07, Young-Jin Lee youngjin.michael@gmail.com wrote:
Hi,
I am a newbie trying to learn Squeak. The squeak book and tutorials says that I need to define a local variable using a pipe like below:
| someMuppet | someMuppet := Muppet new. someMuppet name: 'Elmo'. someMuppet greet.
But when I tried the same code without defining a local variable shown below, I got the expected results, which makes me wonder when I should define a local variable.
anotherMuppet := Muppet new. anotherMuppet name: 'Gookie Monster'. anotherMuppet greet.
My guess is that I need not define a local variable if my code is being executed within a Workspace because all variables such as anotherMuppet will have "Workspace" scope.
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.
Enjoy!
Laurence
Can anyone please explain in more detail about variable scopes?
Thanks in advance.
Young-Jin Lee _______________________________________________ Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Hello,
You mention Croquet as offering alternatives. I have been trying to run Croquet on several different computers but always receive the "Failed to Initiate OpenGL" error however, I recently installed the latest OpenGL on all my computers. Do you know how to deal with this? Also, I get a security error saying my Win32 platform has no good source of entropy. How can I cope with this? If you have any advice I would greatly appreciate it.
Eric Eisaman
On 4/1/07, Laurence Rozier laurence.rozier@gmail.com wrote:
On 3/31/07, Young-Jin Lee youngjin.michael@gmail.com wrote:
Hi,
I am a newbie trying to learn Squeak. The squeak book and tutorials says that I need to define a local variable using a pipe like below:
| someMuppet | someMuppet := Muppet new. someMuppet name: 'Elmo'. someMuppet greet.
But when I tried the same code without defining a local variable shown below, I got the expected results, which makes me wonder when I should define a local variable.
anotherMuppet := Muppet new. anotherMuppet name: 'Gookie Monster'. anotherMuppet greet.
My guess is that I need not define a local variable if my code is being executed within a Workspace because all variables such as anotherMuppet will have "Workspace" scope.
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, Croquetand 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.
Enjoy!
Laurence
Can anyone please explain in more detail about variable scopes?
Thanks in advance.
Young-Jin Lee _______________________________________________ Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Hi, Sorry for the delayed response ... I'm not on a Windows machine at the moment but have applied available fixes to OpenGL problems which you can find on the Croquet list. I've not seen the security error you mention.
Laurence On 5/7/07, Eric Eisaman eric.eisaman@gmail.com wrote:
Hello,
You mention Croquet as offering alternatives. I have been trying to run Croquet on several different computers but always receive the "Failed to Initiate OpenGL" error however, I recently installed the latest OpenGL on all my computers. Do you know how to deal with this? Also, I get a security error saying my Win32 platform has no good source of entropy. How can I cope with this? If you have any advice I would greatly appreciate it.
Eric Eisaman
On 4/1/07, Laurence Rozier laurence.rozier@gmail.com wrote:
On 3/31/07, Young-Jin Lee < youngjin.michael@gmail.com> wrote:
Hi,
I am a newbie trying to learn Squeak. The squeak book and tutorials says that I need to define a local variable using a pipe like below:
| someMuppet | someMuppet := Muppet new. someMuppet name: 'Elmo'. someMuppet greet.
But when I tried the same code without defining a local variable shown
below, I got the expected results, which makes me wonder when I should define a local variable.
anotherMuppet := Muppet new. anotherMuppet name: 'Gookie Monster'. anotherMuppet greet.
My guess is that I need not define a local variable if my code is being executed within a Workspace because all variables such as anotherMuppet will have "Workspace" scope.
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, Croquetand 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.
Enjoy!
Laurence
Can anyone please explain in more detail about variable scopes?
Thanks in advance.
Young-Jin Lee _______________________________________________ Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
squeakland@lists.squeakfoundation.org