[Pharo-project] Where declared global reside... how can they be removed?
Hi everyone, I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate. For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace. If I make a new global variable such as: MySquare := Morph new ...once I define "MySquare" as a global variable I know I can send it many messages like: MySquare openInWorld MySquare color: Color yellow When I'm done and I close the workspace, save the image and save the image. When I open it again it will know what "MySquare" is known in any workspace. How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables? - John
2009/7/17 John Escobedo <letmeshowyou@gmail.com>:
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
          MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
          MySquare openInWorld           MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. Â When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
Smalltalk inspect - gives you all the globals :) And to remove, as in any dictionary , use: Smalltalk removeKey: #MyGlobal but beware, if your global is a class, you'd better remove it using tools (or specialized method for removing classes). My personal advice (or take it as a opinion) : - NEVER USE any globals except from class names. - try to avoid referencing "uncommon" globals directly in methods. Better create an accessor method to it, and put a reference in there, and then use this accessor in the rest of your methods. In this way, if you would want to get rid of it, rename it, or refactor it - you will know that all you need to do is to change a single method, rather than 100000 of methods, which referencing this global.
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
And few things about playing with morphs. Rather than doing this in workspace (and therefore inventing a ways how to get a reference to your morph), i think you'd better to do that in morph's inspector: Morph new inspect; openInWorld now, after you Doit the above, you'll have a new morph on screen and its inspector opened. In inspector's lower pane you can send any messages to morph using 'self' i.e.: instead of: MySquare color: Color yellow in workspace, write: self color: Color yellow in inspector. 2009/7/17 Igor Stasenko <siguctua@gmail.com>:
2009/7/17 John Escobedo <letmeshowyou@gmail.com>:
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
          MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
          MySquare openInWorld           MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. Â When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
Smalltalk inspect - gives you all the globals :) And to remove, as in any dictionary , use: Smalltalk removeKey: #MyGlobal but beware, if your global is a class, you'd better remove it using tools (or specialized method for removing classes).
My personal advice (or take it as a opinion) : - NEVER USE any globals except from class names. - try to avoid referencing "uncommon" globals directly in methods. Better create an accessor method to it, and put a reference in there, and then use this accessor in the rest of your methods. In this way, if you would want to get rid of it, rename it, or refactor it - you will know that all you need to do is to change a single method, rather than 100000 of methods, which referencing this global.
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.
+ 10000000000000000000000
2009/7/17 John Escobedo <letmeshowyou@gmail.com>:
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
MySquare openInWorld MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
Smalltalk inspect - gives you all the globals :) And to remove, as in any dictionary , use: Smalltalk removeKey: #MyGlobal but beware, if your global is a class, you'd better remove it using tools (or specialized method for removing classes).
My personal advice (or take it as a opinion) : - NEVER USE any globals except from class names. - try to avoid referencing "uncommon" globals directly in methods. Better create an accessor method to it, and put a reference in there, and then use this accessor in the rest of your methods. In this way, if you would want to get rid of it, rename it, or refactor it - you will know that all you need to do is to change a single method, rather than 100000 of methods, which referencing this global.
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
John, As Sig already said, globals should be used sparingly. You should read about workspace variables. Personally, I can't stand them, but others like them and you might too. You can also define temporaries in a workspace, something like | mySquare | mySquare := Morph new. ... The problem (or feature, depending on your perspective) is that mySquare will go away as soon as the expressions are evaluated, unless you inspect it or otherwise take steps to keep it around. Workspace variables will stick around, which is why they end up irritating me. I also do not like the implicit definition of them; it's easy to slip spelling, and instead of getting a syntax error, you get broken code, which is the _real_ reason I do not like them. Welcome to Smalltalk, and to the list. Enjoy! Bill -----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of John Escobedo Sent: Thursday, July 16, 2009 7:22 PM To: pharo-project@lists.gforge.inria.fr Subject: [Pharo-project] Where declared global reside... how can they be removed? Hi everyone, I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate. For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace. If I make a new global variable such as: MySquare := Morph new ...once I define "MySquare" as a global variable I know I can send it many messages like: MySquare openInWorld MySquare color: Color yellow When I'm done and I close the workspace, save the image and save the image. When I open it again it will know what "MySquare" is known in any workspace. How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables? - John _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
2009/7/17 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
John,
As Sig already said, globals should be used sparingly. Â You should read about workspace variables. Â Personally, I can't stand them, but others like them and you might too. Â You can also define temporaries in a workspace, something like
| mySquare | mySquare := Morph new. ...
The problem (or feature, depending on your perspective) is that mySquare will go away as soon as the expressions are evaluated, unless you inspect it or otherwise take steps to keep it around. Â Workspace variables will stick around, which is why they end up irritating me. Â I also do not like the implicit definition of them; it's easy to slip spelling, and instead of getting a syntax error, you get broken code, which is the _real_ reason I do not like them.
yeah.. implicit temps - this is what i disabling at first place when using workspaces. IMO, it is very error prone feature.
Welcome to Smalltalk, and to the list. Â Enjoy!
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of John Escobedo Sent: Thursday, July 16, 2009 7:22 PM To: pharo-project@lists.gforge.inria.fr Subject: [Pharo-project] Where declared global reside... how can they be removed?
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
          MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
          MySquare openInWorld           MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. Â When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
Sig, Is there a way to disable the implicit temps? That would be great, because it IS an error waiting to happen. Bill -----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Igor Stasenko Sent: Friday, July 17, 2009 12:07 AM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Where declared global reside... how can they be removed? 2009/7/17 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
John,
As Sig already said, globals should be used sparingly. Â You should read about workspace variables. Â Personally, I can't stand them, but others like them and you might too. Â You can also define temporaries in a workspace, something like
| mySquare | mySquare := Morph new. ...
The problem (or feature, depending on your perspective) is that mySquare will go away as soon as the expressions are evaluated, unless you inspect it or otherwise take steps to keep it around. Â Workspace variables will stick around, which is why they end up irritating me. Â I also do not like the implicit definition of them; it's easy to slip spelling, and instead of getting a syntax error, you get broken code, which is the _real_ reason I do not like them.
yeah.. implicit temps - this is what i disabling at first place when using workspaces. IMO, it is very error prone feature.
Welcome to Smalltalk, and to the list. Â Enjoy!
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of John Escobedo Sent: Thursday, July 16, 2009 7:22 PM To: pharo-project@lists.gforge.inria.fr Subject: [Pharo-project] Where declared global reside... how can they be removed?
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
          MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
          MySquare openInWorld           MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. Â When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig. _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
2009/7/17 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
Sig,
Is there a way to disable the implicit temps? Â That would be great, because it IS an error waiting to happen.
look for them in the workspace menu.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Igor Stasenko Sent: Friday, July 17, 2009 12:07 AM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Where declared global reside... how can they be removed?
2009/7/17 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
John,
As Sig already said, globals should be used sparingly. Â You should read about workspace variables. Â Personally, I can't stand them, but others like them and you might too. Â You can also define temporaries in a workspace, something like
| mySquare | mySquare := Morph new. ...
The problem (or feature, depending on your perspective) is that mySquare will go away as soon as the expressions are evaluated, unless you inspect it or otherwise take steps to keep it around. Â Workspace variables will stick around, which is why they end up irritating me. Â I also do not like the implicit definition of them; it's easy to slip spelling, and instead of getting a syntax error, you get broken code, which is the _real_ reason I do not like them.
yeah.. implicit temps - this is what i disabling at first place when using workspaces. IMO, it is very error prone feature.
Welcome to Smalltalk, and to the list. Â Enjoy!
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of John Escobedo Sent: Thursday, July 16, 2009 7:22 PM To: pharo-project@lists.gforge.inria.fr Subject: [Pharo-project] Where declared global reside... how can they be removed?
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
          MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
          MySquare openInWorld           MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. Â When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
Sig, Thanks. I don't see an option, but I am using the standard toolset. Bill -----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Igor Stasenko Sent: Friday, July 17, 2009 11:09 AM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Where declared global reside... how can they be removed? 2009/7/17 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
Sig,
Is there a way to disable the implicit temps? Â That would be great, because it IS an error waiting to happen.
look for them in the workspace menu.
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of Igor Stasenko Sent: Friday, July 17, 2009 12:07 AM To: Pharo-project@lists.gforge.inria.fr Subject: Re: [Pharo-project] Where declared global reside... how can they be removed?
2009/7/17 Schwab,Wilhelm K <bschwab@anest.ufl.edu>:
John,
As Sig already said, globals should be used sparingly. Â You should read about workspace variables. Â Personally, I can't stand them, but others like them and you might too. Â You can also define temporaries in a workspace, something like
| mySquare | mySquare := Morph new. ...
The problem (or feature, depending on your perspective) is that mySquare will go away as soon as the expressions are evaluated, unless you inspect it or otherwise take steps to keep it around. Â Workspace variables will stick around, which is why they end up irritating me. Â I also do not like the implicit definition of them; it's easy to slip spelling, and instead of getting a syntax error, you get broken code, which is the _real_ reason I do not like them.
yeah.. implicit temps - this is what i disabling at first place when using workspaces. IMO, it is very error prone feature.
Welcome to Smalltalk, and to the list. Â Enjoy!
Bill
-----Original Message----- From: pharo-project-bounces@lists.gforge.inria.fr [mailto:pharo-project-bounces@lists.gforge.inria.fr] On Behalf Of John Escobedo Sent: Thursday, July 16, 2009 7:22 PM To: pharo-project@lists.gforge.inria.fr Subject: [Pharo-project] Where declared global reside... how can they be removed?
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
          MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
          MySquare openInWorld           MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. Â When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig. _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
john soon you will be able to get pharo by example :) Stef On Jul 17, 2009, at 2:22 AM, John Escobedo wrote:
Hi everyone,
I'm new to both Smalltalk and especially to Pharo (and this mailing list). I have a very basic question and would like to be directed to more info or a different mailing list if appropriate.
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
MySquare openInWorld MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
- John
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
I appreciate all the feedback. I learned a lot about the SmallTalk Dictionary this way. "Smalltalk removeKey: #MyGlobal" worked great of course, however I'm now just using "reset variables" in the Shout Workspace window. Even though the latter will clear them all, is there a clear path towards "show me all the variables I've made in the Workspace" ? I realize building full objects would be more correct for a final project, however the tutorials (and my own tinkering) usually find me creating quick things in a Workspace to experiment and I'm just making sure I know and understand how to clean it up later. Will Pharo possibly add any visual behavior to keep track of "floating" objects or add a "variables" window for workspaces? -- John John E. wrote:
For most tutorials (I'm using squeak tutorials), one does a lot of work in a workspace.
If I make a new global variable such as:
MySquare := Morph new
...once I define "MySquare" as a global variable I know I can send it many messages like:
MySquare openInWorld MySquare color: Color yellow
When I'm done and I close the workspace, save the image and save the image. When I open it again it will know what "MySquare" is known in any workspace.
How do I remove "MySquare" and/or the associated object? How could I see or find other such global variables?
- John
-- View this message in context: http://n2.nabble.com/Where-declared-global-reside...-how-can-they-be-removed... Sent from the Pharo Smalltalk mailing list archive at Nabble.com.
participants (5)
-
Igor Stasenko -
John E. -
John Escobedo -
Schwab,Wilhelm K -
Stéphane Ducasse