smalltalk

How to define Pascal variables in PetitParser

半世苍凉 提交于 2019-12-23 11:52:53
问题 Here is the (simplified) EBNF section I'm trying to implement in PetitParser: variable :: component / identifier component :: indexed / field indexed :: variable , $[ , blah , $] field :: variable , $. , identifier What I did was to add all these productions (except identifier ) as ivars of my subclass of PPCompositeParser and define the corresponding methods as follows: variable ^component / self identifier component ^indexed / field identifier ^(#letter asParser, (#word asParser) star)

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).

Refactoring if-chains in Smalltalk without class explosion

时光毁灭记忆、已成空白 提交于 2019-12-23 09:32:30
问题 As Smalltalk discourages the use of caseOf:, what aternatives exists to implement the following situation without class explosion? self condition1 ifTrue: [ self actionForCondition1 ] ifFalse: [ self condition2 ifTrue: [ self actionForCondition2 ] ifFalse: [ self condition3 ifTrue: [ self actionForCondition3 ] ifFalse: [ .... ] ] ] 回答1: If you scroll to near the end of http://www.desk.org:8080/CampSmalltalk/control%20flow you will find the sentence "There are four ways to express a case

How to find which was the wrong message in a Message Not Understood message?

和自甴很熟 提交于 2019-12-22 10:49:54
问题 I want to find the name of the message that triggered the MNU , how do I do that ? For example if I do Transcript explode . This will trigger a MNU because method explode does not exist but how do I find that the name of the message that triggered MNU is "explode" ? 回答1: If I DoIt that, I get a debugger. The title there is MessageNotUnderstood: ThreadSafeTranscript>>explode When I select the first element, I get to see the doesNotUnderstand: aMessage, where aMessage is the message 回答2: Try

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

Smalltalk Pharo ZdcSecureSMTPClient not showing html formatting in GMail?

ⅰ亾dé卋堺 提交于 2019-12-22 08:52:11
问题 I'm using ZdcSecureSMTPClient to send an html formatted string to a gmail account. But when I send it it displays the html encoding as plain text. ie) mailMessage := MailMessage empty. mailMessage setField: 'subject' toString: 'Trying to send html '. mailMessage body: (MIMEDocument contentType: 'text/html\n' content: '<html><head><b> Dear </b></head></html>' This shows is Gmail as: 'html> head> Dear /b>/head>/html>' Using Seaside/Pharo 2.0 one click image. 回答1: What you use to set the mime

Smalltalk Pharo ZdcSecureSMTPClient not showing html formatting in GMail?

邮差的信 提交于 2019-12-22 08:50:41
问题 I'm using ZdcSecureSMTPClient to send an html formatted string to a gmail account. But when I send it it displays the html encoding as plain text. ie) mailMessage := MailMessage empty. mailMessage setField: 'subject' toString: 'Trying to send html '. mailMessage body: (MIMEDocument contentType: 'text/html\n' content: '<html><head><b> Dear </b></head></html>' This shows is Gmail as: 'html> head> Dear /b>/head>/html>' Using Seaside/Pharo 2.0 one click image. 回答1: What you use to set the mime

How do I ask the user for a file name?

邮差的信 提交于 2019-12-22 07:24:11
问题 Searching for the call of a FileDialog I would like to ask the user for a file name in Pharo 4.0 Through the spotter I found class FileDialogWindow with a method answerFileName Looking for the senders of #answerFileName I get to class UITheme where it is called in the method chooseFileNameIn: aThemedMorph title: title extensions: exts path: path preview: preview And from there I come to class TEasilyThemed with the method chooseFileName: title extensions: exts path: path preview: preview From

Explain a piece of Smalltalk code?

旧街凉风 提交于 2019-12-22 05:10:36
问题 I cannot understand this piece of Smalltalk code: [(line := self upTo: Character cr) size = 0] whileTrue. Can anybody help explain it? 回答1: One easy thing to do, if you have the image where the code came from, is run a debugger on it and step through. If you came across the code out of context, like a mailing list post, then you could browse implementers of one of the messages and see what it does. For example, #size and #whileTrue are pretty standard, so we'll skip those for now, but #upTo:

What is the difference between Seaside programmming and other web programming

若如初见. 提交于 2019-12-22 03:44:11
问题 To me it seems the main point of Seaside is that it is more like normal "desktop" programming. The control flow looks much more like "traditional" programming instead of "web" programming. Is that a correct impression? I know it's about Web programming but it's does not looks like it from the programmers side. It looks much more than driving "desktop" applications. Does this clarify the question a bit? 回答1: Your impression is correct. Seaside is designed for what I call a tree-like control