Kilon,

You figured out how to use it, yet you did not use the system to search for an 
explanation ?

From the class comment of Workspace:

===
A workspace can have its own variables, called "workspace variables", to hold 
intermediate results.  For example, if you type into a workspace "x := 5" and 
do-it, then later you could type in "y := x * 2" and y would become 10.
===

In the window menu of Workspace you have 'Inspect variables', 'Reset Variables'.

Check the references to the instance variable 'bindings' of Workspace.

Check the senders of #bindingOf:

Summary:

When evaluating code (do it, inspect it, print it) the expression is compiled. 
Compilation happens in a context. For scripting code this is often nil, but 
Pharo (method code) normally references an object (self). So when evaluating 
from a Workspace, the workspace instance with its bindings is used as context. 
So, these variables are local to the workspace, but behave a bit like a mixture 
between global and instance variables.

HTH,

Sven

> On 28 Dec 2014, at 09:32, kilon alios <kilon.al...@gmail.com> wrote:
> 
> I am not familiar with that part of Pharo because I never use temporary 
> variables in Workspace but I did a little experiment and this is what I found 
> . I followed these 3 steps
> 
> 1) I created 2 Workspaces 
> 2) In first Workspace I put the code 
> 
> |a|
> a:= Morph new.
> a openInWindow .
> 
> 3) In the second Workspace I put the code
> 
> a:= Morph new.
> a openInWindow .
> 
> Now executing both examples give the result you would expect , a morph inside 
> a window BUT if I inspect variable a in both cases , the workspace variable 
> example returns me a Morph as to be expected on the other hand the workspace 
> temporary variable returns me an undefined object. So that leads me to assume 
> here that the temporary variable works as expect by destroying its reference 
> as soon as the code is executed, hence why its called "temporary ;) 
> 
> 
> 
> On Sat, Dec 27, 2014 at 9:28 PM, nacho <0800na...@gmail.com> wrote:
> Hi pharoers,
> In killion video tutorials I see that he uses variables not declaring them
> as temporal (that is | aVariable | ).
> If one does not declare variables as temporal in a workspace what kind of
> variables are them?
> Also why in the tutorial they appear in blue and in my workspace they appear
> in red as if there was something wrong? (actually if I declare all variables
> as temporal using | | then all turn tu blue).
> Thanks in advance and best regards
> Nacho
> 
> 
> 
> 
> -----
> Nacho
> Smalltalker apprentice.
> Buenos Aires, Argentina.
> --
> View this message in context: 
> http://forum.world.st/Question-on-temporal-variables-in-Workspace-tp4797161.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
> 
> 


Reply via email to