Hi all,
If you're typing in a workspace, and you want to get a handle on that workspace so that you can use it in your expressions, how do you refer to it? At the moment, the best I can come up with is SmalltalkWorkspace allInstances at: n where n is a random number. Thanks for your help, Rufus. |
Rufus,
> If you're typing in a workspace, and you want to get > a handle on that workspace so that you can use it in > your expressions, how do you refer to it? (View desktop subViews detect: [:each | each isActive]) presenter or SmalltalkWorkspaceDocument allInstances detect: [:each | each view isActive] should do it. Regards Ian |
> (View desktop subViews detect: [:each | each isActive]) presenter
> > or > > SmalltalkWorkspaceDocument allInstances detect: [:each | each view isActive] > > should do it. They do indeed; thanks a lot for helping, Ian. I was surprised, though, that referring to an object from within that object cannot be done in a more direct way. Cheers, Rufus. |
"Rufus T. Blitzstein" <[hidden email]> wrote in message
news:a4ud9s$tg6$[hidden email]... > > (View desktop subViews detect: [:each | each isActive]) presenter > > > > or > > > > SmalltalkWorkspaceDocument allInstances detect: [:each | each view > isActive] > > > > should do it. > > > They do indeed; thanks a lot for helping, Ian. > > I was surprised, though, that referring to an object from within > that object cannot be done in a more direct way. As a matter of interest, why do you want/need to be able to refer to the workspace? Regards Blair |
In reply to this post by Rufus T. Blitzstein
Rufus,
> I was surprised, though, that referring to an object from within > that object cannot be done in a more direct way. Normally you can, it's to do with the context that the code is being evaluated in. Code evaluated within the context of a method knows it's place in the world, via #self and #super. You can use those as the starting point for exploring the object and it's environment. Code in a workspace is _evaluated_ in the context of the UndefinedObject class (#self and #super both answer the only instance of that class, nil) and not a SmalltalkWorkspace. Think of the workspace as a blackboard that is used to enter and "control" the evaluation of the code, but then plays no part in it's execution. [1] Accessing a workspace from the code being to evaluate it is unusual though, probably why there is no easy way of doing it?. Can I ask why you are wanting to do it? Regards Ian [1] I was going to compare a workspace with the blackboard that Einstein used [2] to arrive at his theories, the blackboard can describe the working of the universe but plays no part in it's operation. Then I started thinking about the consequences of the universe being defined as an UndefinedObject and got scared. Anyone who remembers the short story "The Nine Million Names of God" by ACC will know why :) [2] Quite apposite as he surely would have used Smalltalk if he was around today!! |
In reply to this post by Blair McGlashan
> As a matter of interest, why do you want/need to be able to refer to the
> workspace? Hi Blair, My workspaces have a tendency to grow rapidly to several pages of random scribblings, and sometimes I lose track of what local identifiers I've created in there. I therefore inspect the "workspacePool" of the workspace. If I want to "undeclare" an identifier in a workspace, is it OK simply to send the message "#removeKey:ifAbsent:" to that workspacePool? Thanks for your interest, and while I've got your attention, for your part in creating this marvellous system in the first place. Rufus. |
In reply to this post by Ian Bartholomew
Thanks a lot for explaining about contexts, Ian. "self" was the one of
the first things I tried in the workspace, and now I know why I just got "nil". > Code in a workspace is _evaluated_ in the context of the UndefinedObject > class (#self and #super both answer the only instance of that class, nil) > and not a SmalltalkWorkspace. But why is that the case? If there is no simple answer to this, that's fair enough; my curiosity can wait until I've learnt more about the inner workings of Smalltalk. > [1] I was going to compare a workspace with the blackboard that Einstein > used [2] to arrive at his theories, the blackboard can describe the working > of the universe but plays no part in it's operation. Then I started thinking > about the consequences of the universe being defined as an UndefinedObject > and got scared. Anyone who remembers the short story "The Nine Million > Names of God" by ACC will know why :) Scared the universe might disappear in a puff of logic? Rufus. |
In reply to this post by Rufus T. Blitzstein
"Rufus T. Blitzstein" <[hidden email]> wrote in message
news:a5007k$j90$[hidden email]... > > As a matter of interest, why do you want/need to be able to refer to the > > workspace? > ... > My workspaces have a tendency to grow rapidly to several pages of > random scribblings, and sometimes I lose track of what local > identifiers I've created in there. > > I therefore inspect the "workspacePool" of the workspace. Ah, in that case you want to use the Workspace/Variables command on the Menu bar, or Variables command on the context menu. > > If I want to "undeclare" an identifier in a workspace, is it OK > simply to send the message "#removeKey:ifAbsent:" to that > workspacePool? It would be OK to do that, or you can delete it from the Dictionary inspector opened by one of the Variables commands I mention above. > Thanks for your interest, and while I've got your attention, for > your part in creating this marvellous system in the first place. > Rufus. Thanks. It's always nice to know that one's work is appreciated. Regards Blair |
> Ah, in that case you want to use the Workspace/Variables command on the
Menu > bar, or Variables command on the context menu. I don't think I've got that facility on mine - it's the one that came free with PC Plus. I might treat myself to the full version one day. I'm ashamed to say I hadn't even heard of Smalltalk before Huw Collingbourne's article in that issue introduced it, but once I'd got it running, it immediately felt right. I was bowled over by the fact that there was no distinction between my own code and the code that made the fundamental structures of the language itself - even if..then..else decisions and for..next loops! I am still a novice Smalltalker but already it feels like the language I've been waiting for all my life. Rufus. |
"Rufus T. Blitzstein" <[hidden email]> wrote in message
news:a50a62$7ne$[hidden email]... > > Ah, in that case you want to use the Workspace/Variables command on the > Menu > > bar, or Variables command on the context menu. > > I don't think I've got that facility on mine - it's the one > that came free with PC Plus. I might treat myself to the > full version one day. > You might, then, be interested to know that a free evaluation license for Dolphin Smalltalk 4.0 is available here: http://www.object-arts.com/Trial/index.html I think you will find that Dolphin Smalltalk 4.0 is substantially improved over the version you have been using, and Dolphin 5.0 is "coming soon" (see http://www.object-arts.com/Home.htm). A cost efficient way to acquire a license to Dolphin 4.0 Value Edition is to purchase Ted Bracht's book about Dolphin, "The Dolphin Smalltalk Companion" (again see the OA homepage, link above). The book includes a complementary license to DVE 4.0, which makes it a bit of a bargain. In the UK the book can be purchased from Amazon, or from PC Bookshop, the latter having the advantage of next day free delivery: http://www.pcbooks.co.uk/mainpage.asp?Stocknumber=1238123 Regards Blair |
In reply to this post by Rufus T. Blitzstein
> But why is that the case? If there is no simple answer to this, that's
> fair enough; my curiosity can wait until I've learnt more about the > inner workings of Smalltalk. Ummm. All I can give is the simple answer "because that's the way it works". When you compile or evaluate code you have to specify a context and when there is no specific context, the class that a method belongs to for example, then UndefinedObject is automatically used. It doesn't seem compulsory - see below - but there may well be reasons that I don't know anything about. Blair? Modify (this is D4 but I imagine it will be the same in 2.1) SmalltalkWorkspace>>evaluateIt by adding the following as the first line. self evaluationContext: self. If you then open a workspace and evaluate the following then the workspace's caption changes. self topShell caption: 'Hello, world' Regards Ian |
Free forum by Nabble | Edit this page |