smalltalk

smalltalk block - can I explicitly set the returning value and stop executing the block?

冷暖自知 提交于 2019-12-07 14:39:31
问题 The return value of #value: message, when sent to a block, is the value of the last sentence in that block. So [ 1 + 2. 3 + 4. ] value evaluates to 7. I find that hard to use sometimes. Is there a way to explicitly set the returning value and stop executing the block? For exercise, try rewriting this block without using my imaginary #return: message and see how ugly it gets. I must be missing something. [ :one :two | one isNil ifTrue: [ two isNil ifTrue: [ self return: nil ] ifFalse: [ self

“:=” and binary message precedence in Smalltalk

社会主义新天地 提交于 2019-12-07 09:34:05
问题 I am attempting to learn Smalltalk through the tutorials included with Dolphin Smalltalk X6. My question deals with the evaluation of expressions with multiple messages. My understanding is that simple messages are evaluated first, then binary messages, and finally keyword messages (with the exception of code in parenthesis). However, I am having trouble applying this understanding to the second line in the following example (found in the Dolphin Smalltalk tutorial). playground := Playground

Is there any ETL tool for any Smalltalk dialect?

我是研究僧i 提交于 2019-12-07 09:32:12
问题 ...like Talend for Java, for instance, but that allows to implement processes programatically. Multiple data sources, orchestration, calculated fields, pivot tables are some of the features I would like to have. 回答1: We've build on top of Moose for a ERP data conversion project. Works well with smaller amounts of data (that fit in a 32-bit image). In ETL with multiple sources, just use an image for each input stream/step, connect them together through files or sockets. The visualization was

How do I copy a stacktrace out of the debugger in Pharo?

北慕城南 提交于 2019-12-07 07:10:12
问题 How do I copy a stacktrace out of the debugger in Pharo? I know there's the Debug.log file somewhere near the image, but I'm far too lazy to navigate out of Pharo, to the file system, find the folder, and browse through a gigantic text file if there's a stack trace right in front of me. 回答1: I know a way, but it is not the best. When you are inside the debugger, right click -> "mail out bug report" and there you can copy/paste the stacktrace heheheh Another option is to bring ctrl + click in

How does the implementation of #doesNotUnderstand in the Object class result in opening a debugger in Squeak smalltalk?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-07 06:42:53
问题 I know that the implementation signals a MessageNotUnderstood exception, but how does that end up opening a debugger? 回答1: When an Exception remains unhandled after it has been signalled, its #defaultAction is invoked. MessageNotUnderstood>>defaultAction delegates to Error>>defaultAction, which signals an UnhandledError (another Exception). This exception, in turn, has a defaultAction whose code reads like this: ^ ToolSet debugError: self exception ...which opens the debugger if you use the

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

Smalltalk: Writing output to a file

浪子不回头ぞ 提交于 2019-12-07 04:49:49
问题 Usually with my output I am writing it to the Transcript with... Transcript show: How does one write the output to a file instead? 回答1: You want to use a FileStream See this link describing FileStreams Excerpt below: FileStream FileStreams support all of ExternalStreams protocol. They can be created to read, write, readWrite or append from/to a file. Creation: * for reading: aStream := FileStream readonlyFileNamed:aFilenameString * to read/write an existing file: aStream := FileStream

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

Elegant way to remove the last part of a string?

♀尐吖头ヾ 提交于 2019-12-07 00:26:24
问题 In Smalltalk, if given the string 'OneTwoThree', I'd like to remove the last 'Three' part, .e., In Squeak method finder notation: 'OneTwoThree' . 'Three' . 'OneTwo' . The best I can come up with is: 'OneTwoThree' allButLast: 'Three' size , but it doesn't feel very Smalltalk-ish, because it uses the substring length, rather than the substring itself. How would you code it? 回答1: 'OneTwoThree' readStream upToAll: 'Three' 回答2: I usually use #copyReplaceAll:with: method, if the last string is not

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