How to use pool dictionaries in a workspace?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

How to use pool dictionaries in a workspace?

Louis LaBrunda
Hi,

When I want to use values defined in a pool dictionary in VA Smalltalk, I
put the following lines at the top of the workspace (I often save
workspaces for repeat use):

"
EtWindow defaultEvaluationPools: (EtWindow defaultEvaluationPools asSet
addAll: #(#PoolDictionaryName)) asArray.
EtWindow defaultEvaluationPools: nil.
"

If I execute the first line (not counting the comment " line and not
wrapped) The named pool dictionary is available to the workspace.  I can
test code as if the pool dictionary were specified for the class and I was
writing a method.  This way when I'm happy with the code, I can just copy
it to a method and use it as is.  The second line puts things back the way
it was.

I would love to be able to do this with Squeak.  Does anyone have any idea
how to do this with Squeak?  Or point me in the right direction?

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to use pool dictionaries in a workspace?

Bob Arning-2
Have you tried

Workspace addLookupPool: MyPool

?

Although I wonder why one would go to the trouble. Why not just put the code in a method that can reference the pool normally?

Cheers,
Bob

On 3/5/13 1:56 PM, Louis LaBrunda wrote:
Hi,

When I want to use values defined in a pool dictionary in VA Smalltalk, I
put the following lines at the top of the workspace (I often save
workspaces for repeat use):

"
EtWindow defaultEvaluationPools: (EtWindow defaultEvaluationPools asSet
addAll: #(#PoolDictionaryName)) asArray.
EtWindow defaultEvaluationPools: nil.
"

If I execute the first line (not counting the comment " line and not
wrapped) The named pool dictionary is available to the workspace.  I can
test code as if the pool dictionary were specified for the class and I was
writing a method.  This way when I'm happy with the code, I can just copy
it to a method and use it as is.  The second line puts things back the way
it was.

I would love to be able to do this with Squeak.  Does anyone have any idea
how to do this with Squeak?  Or point me in the right direction?

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
[hidden email] http://www.Keystone-Software.com






Reply | Threaded
Open this post in threaded view
|

How to use pool dictionaries in a workspace?

Louis LaBrunda
Hi Bob,

>Have you tried
>Workspace addLookupPool: MyPool?

Thanks, that works great although the #removeLookupPool: doesn't seem to
turn it off but I'm not sure I care.

>Although I wonder why one would go to the trouble. Why not just put the
>code in a method that can reference the pool normally?

One could say that about anything you might want to play with in a
workspace.  As I said, I often work up code in a workspace and then copy it
to a method when I'm happy with it.  If I can't use pool references in the
workspace, I then have to change things when I want to make a real method.

Thanks again for the help.

Lou

>On 3/5/13 1:56 PM, Louis LaBrunda wrote:
>> Hi,
>>
>> When I want to use values defined in a pool dictionary in VA Smalltalk, I
>> put the following lines at the top of the workspace (I often save
>> workspaces for repeat use):
>>
>> "
>> EtWindow defaultEvaluationPools: (EtWindow defaultEvaluationPools asSet
>> addAll: #(#PoolDictionaryName)) asArray.
>> EtWindow defaultEvaluationPools: nil.
>> "
>>
>> If I execute the first line (not counting the comment " line and not
>> wrapped) The named pool dictionary is available to the workspace.  I can
>> test code as if the pool dictionary were specified for the class and I was
>> writing a method.  This way when I'm happy with the code, I can just copy
>> it to a method and use it as is.  The second line puts things back the way
>> it was.
>>
>> I would love to be able to do this with Squeak.  Does anyone have any idea
>> how to do this with Squeak?  Or point me in the right direction?
>>
>> Lou
>> -----------------------------------------------------------
>> Louis LaBrunda
>> Keystone Software Corp.
>> SkypeMe callto://PhotonDemon
>> mailto:[hidden email] http://www.Keystone-Software.com
>>
>>
>>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to use pool dictionaries in a workspace?

Bert Freudenberg
On 2013-03-05, at 20:51, Louis LaBrunda <[hidden email]> wrote:

> Hi Bob,
>
>> Have you tried
>> Workspace addLookupPool: MyPool?
>
> Thanks, that works great although the #removeLookupPool: doesn't seem to
> turn it off but I'm not sure I care.

The values you use are copied into the Workspace instance's own bindings.

Maybe that's what you're seeing?

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: How to use pool dictionaries in a workspace?

Bob Arning-2
In reply to this post by Louis LaBrunda

On 3/5/13 2:51 PM, Louis LaBrunda wrote:
> Hi Bob,
>
>> Have you tried
>> Workspace addLookupPool: MyPool?
> Thanks, that works great although the #removeLookupPool: doesn't seem to
> turn it off but I'm not sure I care.
What did you write to add the pool to the workspace lookups?
>
>> Although I wonder why one would go to the trouble. Why not just put the
>> code in a method that can reference the pool normally?
> One could say that about anything you might want to play with in a
> workspace.
I'm not opposed to workspaces, but when you are spending energy to make
a workspace do what a class & method will already provide, seems like
re-inventing the wheel.
> As I said, I often work up code in a workspace and then copy it
> to a method when I'm happy with it.  If I can't use pool references in the
> workspace, I then have to change things when I want to make a real method.
I don't understand this part. If you put it in a method from the start,
then when it works, you're done.

Oh, any any guesses what Thunderbird thinks your name really is? ;-)

>
> Thanks again for the help.
>
> Lou
>
>> On 3/5/13 1:56 PM, Louis LaBrunda wrote:
>>> Hi,
>>>
>>> When I want to use values defined in a pool dictionary in VA Smalltalk, I
>>> put the following lines at the top of the workspace (I often save
>>> workspaces for repeat use):
>>>
>>> "
>>> EtWindow defaultEvaluationPools: (EtWindow defaultEvaluationPools asSet
>>> addAll: #(#PoolDictionaryName)) asArray.
>>> EtWindow defaultEvaluationPools: nil.
>>> "
>>>
>>> If I execute the first line (not counting the comment " line and not
>>> wrapped) The named pool dictionary is available to the workspace.  I can
>>> test code as if the pool dictionary were specified for the class and I was
>>> writing a method.  This way when I'm happy with the code, I can just copy
>>> it to a method and use it as is.  The second line puts things back the way
>>> it was.
>>>
>>> I would love to be able to do this with Squeak.  Does anyone have any idea
>>> how to do this with Squeak?  Or point me in the right direction?
>>>
>>> Lou
>>> -----------------------------------------------------------
>>> Louis LaBrunda
>>> Keystone Software Corp.
>>> SkypeMe callto://PhotonDemon
>>> mailto:[hidden email] http://www.Keystone-Software.com
>>>
>>>
>>>
> -----------------------------------------------------------
> Louis LaBrunda
> Keystone Software Corp.
> SkypeMe callto://PhotonDemon
> mailto:[hidden email] http://www.Keystone-Software.com
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Re: How to use pool dictionaries in a workspace?

Louis LaBrunda
In reply to this post by Bert Freudenberg
Yes, in the same workspace they were still there, in another workspace they
are gone so you are right.

Lou

On Tue, 5 Mar 2013 20:57:45 +0100, Bert Freudenberg <[hidden email]>
wrote:

>On 2013-03-05, at 20:51, Louis LaBrunda <[hidden email]> wrote:
>
>> Hi Bob,
>>
>>> Have you tried
>>> Workspace addLookupPool: MyPool?
>>
>> Thanks, that works great although the #removeLookupPool: doesn't seem to
>> turn it off but I'm not sure I care.
>
>The values you use are copied into the Workspace instance's own bindings.
>
>Maybe that's what you're seeing?
>
>- Bert -
>
>
>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

How to use pool dictionaries in a workspace?

Louis LaBrunda
In reply to this post by Bob Arning-2
>>> Although I wonder why one would go to the trouble. Why not just put the
>>> code in a method that can reference the pool normally?
>> One could say that about anything you might want to play with in a
>> workspace.
>I'm not opposed to workspaces, but when you are spending energy to make
>a workspace do what a class & method will already provide, seems like
>re-inventing the wheel.
>> As I said, I often work up code in a workspace and then copy it
>> to a method when I'm happy with it.  If I can't use pool references in the
>> workspace, I then have to change things when I want to make a real method.
>I don't understand this part. If you put it in a method from the start,
>then when it works, you're done.

I often have to play with objects (not so much in Squeak but in my VA
Smalltalk work) that would cause problems if I instantiated them in order
to test a new method.  Sometimes I can't even test them on my computer but
have to test them in production (they want to talk to some host that I
don't have access to).  If I instantiate them they start doing things I
don't want them to do and they interfere with the testing.  So, I can and
must do a lot in a workspace.  It may not be ideal but that's life.

Also, if you take a look at the posts between me and Bert about Minecraft,
you will see that Bert mentioned not being able to access pool values in a
workspace as a negative for using a pool dictionary.  Thanks to your
answer, everybody is happy:))

>Oh, any guesses what Thunderbird thinks your name really is? ;-)

No, but I can always use a good laugh:))

Lou
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to use pool dictionaries in a workspace?

Tobias Pape
Hey Lou

Am 05.03.2013 um 22:18 schrieb Louis LaBrunda <[hidden email]>:

>>> One could say that about anything you might want to play with in a
>>> workspace.
>> I'm not opposed to workspaces, but when you are spending energy to make
>> a workspace do what a class & method will already provide, seems like
>> re-inventing the wheel.
>>> As I said, I often work up code in a workspace and then copy it
>>> to a method when I'm happy with it.  If I can't use pool references in the
>>> workspace, I then have to change things when I want to make a real method.
>> I don't understand this part. If you put it in a method from the start,
>> then when it works, you're done.
>
> I often have to play with objects (not so much in Squeak but in my VA
> Smalltalk work) that would cause problems if I instantiated them in order
> to test a new method.  Sometimes I can't even test them on my computer but
> have to test them in production (they want to talk to some host that I
> don't have access to).  If I instantiate them they start doing things I
> don't want them to do and they interfere with the testing.  So, I can and
> must do a lot in a workspace.  It may not be ideal but that's life.


I can relate there ;)

I am curious why you want to use Pool Dictionaries in the first place.
Not that I question them, but I have up until now never hat the necessity
to use them, so I would be delighted to see why they are useful :)

Best
        -Tobias
Reply | Threaded
Open this post in threaded view
|

Re: How to use pool dictionaries in a workspace?

Bert Freudenberg
On 2013-03-06, at 10:36, Tobias Pape <[hidden email]> wrote:

> I am curious why you want to use Pool Dictionaries in the first place.
> Not that I question them, but I have up until now never hat the necessity
> to use them, so I would be delighted to see why they are useful :)
>
> Best
> -Tobias


They're pretty useful for constants you want to share across class hierarchies.

E.g. all the OpenGL constants are in a pool dict. Makes for simpler-to-read code.

Lou uses it for the Minecraft ids. Compare:

        mc blockAt: {x. y. z} put: #(35 "wool" 10 "purple)

vs

        mc blockAt: {x. y. z} put: PurpleWool

vs

        mc blockAt: {x. y. z} put: MinecraftBlock purpleWool

Any better idea?

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Re: How to use pool dictionaries in a workspace?

Louis LaBrunda
In reply to this post by Tobias Pape
Hi Tobias,

Bert's answer pretty much covers it.  I would add that not only does your
code look better but it is easier to write in the first place.  To use
Bert's example, isn't it easier to remember that you want to put PurpleWool
than a two element array with a 35 and a 10 in it.

Lou

>Hey Lou
>Am 05.03.2013 um 22:18 schrieb Louis LaBrunda <[hidden email]>:
>
>>>> One could say that about anything you might want to play with in a
>>>> workspace.
>>> I'm not opposed to workspaces, but when you are spending energy to make
>>> a workspace do what a class & method will already provide, seems like
>>> re-inventing the wheel.
>>>> As I said, I often work up code in a workspace and then copy it
>>>> to a method when I'm happy with it.  If I can't use pool references in the
>>>> workspace, I then have to change things when I want to make a real method.
>>> I don't understand this part. If you put it in a method from the start,
>>> then when it works, you're done.
>>
>> I often have to play with objects (not so much in Squeak but in my VA
>> Smalltalk work) that would cause problems if I instantiated them in order
>> to test a new method.  Sometimes I can't even test them on my computer but
>> have to test them in production (they want to talk to some host that I
>> don't have access to).  If I instantiate them they start doing things I
>> don't want them to do and they interfere with the testing.  So, I can and
>> must do a lot in a workspace.  It may not be ideal but that's life.
>
>
>I can relate there ;)
>
>I am curious why you want to use Pool Dictionaries in the first place.
>Not that I question them, but I have up until now never hat the necessity
>to use them, so I would be delighted to see why they are useful :)
>
>Best
> -Tobias
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:[hidden email] http://www.Keystone-Software.com


Reply | Threaded
Open this post in threaded view
|

Re: How to use pool dictionaries in a workspace?

Tobias Pape
In reply to this post by Bert Freudenberg
Am 06.03.2013 um 14:03 schrieb Bert Freudenberg <[hidden email]>:

> On 2013-03-06, at 10:36, Tobias Pape <[hidden email]> wrote:
>
>> I am curious why you want to use Pool Dictionaries in the first place.
>> Not that I question them, but I have up until now never hat the necessity
>> to use them, so I would be delighted to see why they are useful :)
>>
>> Best
>> -Tobias
>
>
> They're pretty useful for constants you want to share across class hierarchies.
>
> E.g. all the OpenGL constants are in a pool dict. Makes for simpler-to-read code.
>
> Lou uses it for the Minecraft ids. Compare:
>
> mc blockAt: {x. y. z} put: #(35 "wool" 10 "purple)
>
> vs
>
> mc blockAt: {x. y. z} put: PurpleWool
>
> vs
>
> mc blockAt: {x. y. z} put: MinecraftBlock purpleWool
>
> Any better idea?


No. I personally would use the last one :)

Best
        -tobias