squeak

How can I add methods to a class at runtime in Smalltalk?

为君一笑 提交于 2019-12-30 01:33:28
问题 I'm building a Smalltalk API to an XML-based web service. The XML service is so regular that, rather than write the methods by hand, I figured I'd just override #doesNotUnderstand: to dynamically add methods via MyApi class>>compile: , then call all the methods once in a workspace, then remove the DNU and have my nice API. This works great, but passing a giant string to #compile: just feels really wrong to me; in Python and other languages, I'd be able to attach a nicely syntax-checked lambda

How do I display the new Squeak background in my trunk image?

不想你离开。 提交于 2019-12-24 15:16:27
问题 I have a Squeak 4.3 image that I have updated through 4.4 by using the trunk update stream, which pulls down source code updates from the Monticello repository here How do I get the new 4.4 desktop? In particular, how do I replace the brown antique paper background with the new grey Ulam Spiral background? 回答1: You can download the wallpaper itself here. (This URL points to the wallpaper of the current Squeak release, but you ought to have at least 6 months from today before it changes :) )

Generating all combinations from collections in Smalltalk

好久不见. 提交于 2019-12-24 02:33:24
问题 I've seen this problem resolved for C# and other languages but not for Smalltalk. I have 3 collections, for example: a := #(3 4 5). b := #(4 1 2). c := #(5 2 3). and I need to make all possible combinations, i. e.: #(3 4 5) #(3 4 2) #(3 4 3) #(3 1 5) #(3 1 2) #(3 1 3) #(3 2 5) #(3 2 2) #(3 2 3) #(4 4 5) ... I have seen in Squeak and Pharo there is combinations:atATimeDo: but I don't get how to use it for this case. This is not homework. Any help? 回答1: here is the code from Smalltalk/X's class

Squeak Smalltalk, why sometimes the reduced method doesn't work?

蹲街弑〆低调 提交于 2019-12-23 22:01:12
问题 (2332 / 2332) reduced (2332 / 2) reduced (2332 / 322) reduced (1166/161) (2332 / 3) reduced (2332/3) (2332 / 2432423) reduced (2332/2432423) Look at the above codes. The first and second, when printed, do not work. The MessageNotUnderstood window pops up. And the 3rd, 4th, 5th code are okay. Results come out right. Why does the reduced method not work? Is it because the reduced method fails to handle final results which are integers like Uko guesses ? 回答1: Fractions are reduced automatically

Pharo Smalltalk: Reading from TextMorph

拟墨画扇 提交于 2019-12-23 19:08:19
问题 In Smalltalk using Pharo, I'm creating an application that reads the user input and does X. So far I've managed to make a TextMorph that a user could enter a value into, but I'm unsure of how to read from TextMorphs and then do something with the value. Any ideas? Thanks 回答1: Well, you can simply send text to your morph and get it's contents. So you could have a button and when button is pressed you do something with contents: input := TextMorph new. button := SimpleButtonMorph new target:

new line in squeak

↘锁芯ラ 提交于 2019-12-23 09:58:27
问题 i want to do something like this: Transcript show: '\n'. how? 回答1: Use the following: Transcript cr You can use it after a value via a cascade: Transcript show: 123; cr 回答2: From my (long) experience, missing character escapes are one of the few things that are missing in Smalltalk. For streaming, solutions using cr, tab etc. are ok. However, if you need a particular control character in a string, this may be ugly and hard to read (using "streamContents:", or "withCRs" to add a newLine).

Message forwarding in Smalltalk

人盡茶涼 提交于 2019-12-22 08:54:11
问题 So I'm writing an application where one object has a bunch of delegate objects that it forwards messages to. The idea is that I can say someObject sendMessage:aMessage and aMessage will be sent to all of someObject's delegates (for any value of aMessage). The only way I've been able to do this is something like: sendMessage:aMessage | sel chunks kwords arglist msg | chunks := aMessage findTokens:' '. kwords := Array new:(chunks size). arglist := Array new:(chunks size). 1 to: (chunks size) do

Squeak or Pharo for the beginning Smalltalker?

核能气质少年 提交于 2019-12-20 10:17:36
问题 I am a Rubyist that is just starting to dabble in Smalltalk and am trying to chose an implementation to experiment with. It seems like Squeak or Pharo would be a good choice, but I'm having trouble finding current information to help decide which one would be better. Much of what I find via Google searches is from a couple of years ago and may no longer be relevant. Is there a clear favorite these days? If not, what are the pros and cons of each? 回答1: To certain extent, it is a matter of

How can I add an item in the World-menu of Pharo 4.0?

两盒软妹~` 提交于 2019-12-18 04:59:13
问题 How can I add a new item - Workspace openLabel: 'Workspace' - to the World-menu of Pharo 4.0 ? (What can I say... I prefer Workspace over the new what's-it-called. :-) I've looked at several menu-related items in the Browser, but couldn't really make head or tails of it. I also tried to find where the menu is stored (it must be somewhere, right?), but couldn't find it. Also, how would I go about to add it to one of the existing sub-menues of World-menu, and how could I create a new sub-menu

Is it possible to extend an individual object in Smalltalk

烂漫一生 提交于 2019-12-18 03:36:27
问题 I'm doing research in Smalltalk reflection, and I was wondering if it was possible to extend an individual object like that would be possible for instance in Ruby. With this I mean a selector that only particular objects respond to. Here is some Ruby code that states what I mean. For clarification: in Ruby this open a virtual class for this object, and extends it with a new definition. The vital part here is that nothing changes to the class definition! o = Object.new o.instance_eval {def foo