smalltalk

Implementation Strategies for Object Orientation

核能气质少年 提交于 2019-12-10 02:36:37
问题 I'm currently learning Smalltalk in the Squeak environment and I'm reading "Squeak - A Quick Trip To ObjectLand". I enter the object-oriented paradigm with some prior knowledge from Python and Java and this sentence from the book on page 36 has made me think: Smalltalk is a class-based implementation of an object-oriented language. Short sentence but very interesting. In OO all terms like class, object, instance seem to be well-defined and seem to point to the one and only true meaning and

What is the correct way to test Unicode support in a Smalltalk implementation?

江枫思渺然 提交于 2019-12-08 20:38:25
问题 Given any Smalltalk flavor, how should I proceed to check if Unicode is supported? In case of not having support, how can I detect at which level is missing (VM, font, Converter, etc)? 回答1: At the VM level you can try Character codePoint: 256 or Character codePoint: 65536 (some Smalltalks may use value: instead of codePoint: still). Converter APIs differ between dialects too, but chances are that if the VM supports Unicode so will the converters. As far as I know, no Smalltalk fully supports

Difference between new and initialize in Smalltalk?

别来无恙 提交于 2019-12-08 17:07:27
问题 A newbie question, what is the difference between new and initialize? 回答1: Exactly. When you send the message #new, it not only creates the object, but sends the messagge #initialize. This let you customize the initialization of objects. Look: Behavior >> new "Answer a new initialized instance of the receiver (which is a class) with no indexable variables. Fail if the class is indexable." ^ self basicNew initialize And then: ProtoObject >> initialize "Subclasses should redefine this method to

How to access the jQuery event object in a Seaside callback

时光怂恿深爱的人放手 提交于 2019-12-08 16:39:33
问题 Basically, I want to translate the following into Seaside Smalltalk: $(".myDiv").bind('click', function(e) { console.log(e); }); Besides that I don't want to console.log the event, but access it in my ajax callback. The most promising approach seemed to be something like html div onClick: (html jQuery ajax callback: [:v | self halt] value: (???); with: 'Foo'. But I couldn't find any way to access the event that caused the callback. Intuitively, I would try html jQuery this event for the ???

Poker Hands modeling question

独自空忆成欢 提交于 2019-12-08 09:14:52
问题 I'm modeling a Poker game and I have a little design doubt: I've a PokerHand , which is composed by 5 PokerCard s. Should Straight , ThreeOfAKind , Poker , etc be subclasses of PokerHand ? Or should they be symbols returned by a PokerHand method that computes what kind of hand it is? My rationale for subclassing PokerHand is that it would make checking winner hands much easier and faster, but I'm not sure this is good engineering... Is there any design pattern that would fit here? Thanks! 回答1

Squeak SecureSMTPClient to send HTML email

对着背影说爱祢 提交于 2019-12-08 07:14:38
问题 I am having trouble figuring out how to send an html e-Mail using SecureSMTPClient . The e-Mail client always shows it as plaintext, which means that the MIME is not getting set, i.e. SecureSMTPClient forgets to send: MIME-Version: 1.0 Content-Type: text/html; charset=utf-8 eventhough I specify text/html . Here is the code title:='title1'. content:='<a href="myurl">a link</a>'. smtpClient := SecureSMTPClient new. smtpClient user: senderMailAddress. smtpClient password: pw. smtpClient

Get sender of a message in Smalltalk

拥有回忆 提交于 2019-12-08 06:17:44
问题 Is there a practical way to get the sender of a message in Smalltalk without manually passing self as a Parameter? To be more concrete: I want to add a class specific prefix to an ID that gets passed to my class, so if ClassA sends (on class side) ClassB doSomethingWith: 'myId'. ClassB should internally treat 'myId' as 'ClassB-myId' or something similar. I have implemented this with an additional parameter which has to be self ClassB doSomethingWith: 'myId' for: self. but I would be very glad

FileDirectory and ReferenceStream Class equivalents in Pharo?

北慕城南 提交于 2019-12-08 01:10:33
问题 I'm doing the persistance example at: http://book.seaside.st/book/advanced/persistency/image-based-persistency It involves creating a method that uses the FileDirectory class like this: SMFileDatabase class>>backupDirectory ^ (FileDirectory default directoryNamed: self name) assureExistence. Pharo seems to be unable to find the Class and the closest that comes out in search is FileDirectoryWrapper. Will this do? NB. I can't figure this out myself since I've never used FileDirectory or

Smalltalk and Assertions

孤人 提交于 2019-12-07 22:53:18
问题 Tryng out some smalltalk + TDD + "good practices" I've run into a kinda ugly block: How do I do an assertion in GNU Smalltalk? I'm just looking for a simple ifFalse: [Die] kind of thing 回答1: This is the code for assert: from Squeak (which I recommend you use rather than GNU): assert: aBlock "Throw an assertion error if aBlock does not evaluates to true." aBlock value ifFalse: [AssertionFailure signal: 'Assertion failed'] 回答2: as well as self assert: [ ... some block ] works for blocks & non

Packages for developing static web sites in Smalltalk?

陌路散爱 提交于 2019-12-07 19:14:19
问题 What would be good (cross Smalltalk, mantained, documented) web frameworks or packages (in terms of fewer things to learn/adapt) to use for implementing a static web site with really few forms? .i.e. : a search box and a contact form. I have no "model" or application behind, so I'm not searching for CMS or web application capabilities. There is any example or simple script of a static web site developed in any web frameworks? please I'm NOT interested in counter or 'Hello World' examples. The