pharo

how to stream a collection backwards without copies?

萝らか妹 提交于 2019-12-07 06:24:19
问题 I would like to know how to stream a collection backwards without copies in Pharo/Squeak. For example, to stream #(1 2 3) so stream next returns 3 , then 2 , then 1 . I know I could just use collection reversed readStream , but reversed copies. 回答1: You could use a Generator: | coll stream | coll := #(1 2 3). stream := Generator on: [:g | coll reverseDo: [:ea | g yield: ea]]. stream next Generators let you wrap a streaming interface around any piece of code, basically. 回答2: Create the

What's the difference between Polymorph and Spec?

偶尔善良 提交于 2019-12-07 02:02:52
问题 Recently a Spec documentation was released on-line, how it is related with the Polymorph project? It would be nice to read about the future of these projects. Is Polymorph discontinued? 回答1: Polymorph is a UI framework. Spec is a UI description framework based on literal arrays. In other words the widgets you see on the screen come from Polymorph. A UI builder takes a Spec specification and builds those widgets: "here's a button of this size, and this is its name". In Squeak, the same

FileDirectory and ReferenceStream Class equivalents in Pharo?

六眼飞鱼酱① 提交于 2019-12-06 11:54:06
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 FileDirectoryWrapper before so I'm in the dark. Later edit: Found another one ReferenceStream. They both seem

Packages for developing static web sites in Smalltalk?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:27:46
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 examples I've seen from Seaside looks too complicated, too many nested blocks with the "programmatic

Smalltalk ReferenceStream has problems with new instance variables?

∥☆過路亽.° 提交于 2019-12-06 04:45:39
问题 In Pharo Smalltalk I'm using ReferenceStream to serialise a list of objects -- here's the class definition of the objects I'm serialising: Object subclass: #Task instanceVariableNames: 'title notes list project dateNextAction dateCreated dateCompleted importance selected' classVariableNames: 'Database' poolDictionaries: '' category: 'ToDo' I'm using the SMFileDatabase method described here: http://book.seaside.st/book/advanced/persistency/image-based-persistency This has been working well,

Draw table in Pharo

醉酒当歌 提交于 2019-12-06 03:47:29
问题 I’d like to display a table of values and be able to select cells. How would I do this in Pharo Smalltalk? I’ve heard talk of Morphic widgets able to do this, but I’m still really new to Smalltalk. 回答1: I would look into TreeModel class side examples. I used to do that: tree := TreeModel new. tree openWithSpec. tree columns: (Array with: (TreeColumnModel new displayBlock: [:node | node content first asString ]; headerLabel: 'Name'; yourself) with: (TreeColumnModel new displayBlock: [:node |

The use of “>>” in Pharo/Smalltalk

為{幸葍}努か 提交于 2019-12-06 01:22:16
I am implementing futures in Pharo. I came across this website http://onsmalltalk.com/smalltalk-concurrency-playing-with-futures . I am following this example and trying to replicate it on Pharo. However, I get to this point the last step and I have no idea what ">>" means: This symbol is not also included as part of Smalltalk syntax in http://rigaux.org/language-study/syntax-across-languages-per-language/Smalltalk.html . BlockClosure>>future ^ SFuture new value: self fixTemps I can see future is not a variable or a method implemented by BlockClosure. What should I do with this part of the

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

不羁岁月 提交于 2019-12-05 21:10:21
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" ? 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 Try this: [Transcript explode] on: MessageNotUnderstood do: [:ex| ex message selector] The exception's message is an

How to bind a LabelMorph/TextMorph to a variable so that the Morph reflects changes of the variable?

这一生的挚爱 提交于 2019-12-05 16:19:03
I have an object with a variable containing a String. I have a window containing a LabelMorph/TextMorph (or some other Morph that displays Text?). How do i bind the LabelMorph/TextMorph to the variable, so that the label updates when the String in the variable changes? classic Smalltalk-80 dependent/change/update mechanism? Pharo Announcement framework? something different?? How would i do this? Which Morph should i use? Depends on what you want to achieve. You might want to take a look at a way to do it with Glamour in a current Moose image. In a workspace, do-it: GLMBasicExamples new

Smalltalk Pharo ZdcSecureSMTPClient not showing html formatting in GMail?

这一生的挚爱 提交于 2019-12-05 15:56:13
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. What you use to set the mime type is not what is expected (additionally, the content of the message should be in body , not head ). Use