smalltalk

How can I get all the methods in a Protocol?

一笑奈何 提交于 2020-01-12 15:09:08
问题 How can I get a collection of all the (class) methods in a given protocol in smalltalk/squeak/pharo? I'm trying to collect the values returned by a group of methods. I don't want to have to store the methods in an instance or class variable. So I though I could add them to a protocol and in this way to "mark" them. Thanks. 回答1: In Pharo, the method you're looking for is ClassDescription>>allMethodsInCategory: : | selectors | selectors := MyClass allMethodsInCategory: #'protocol name'. To find

How can I get all the methods in a Protocol?

青春壹個敷衍的年華 提交于 2020-01-12 15:07:21
问题 How can I get a collection of all the (class) methods in a given protocol in smalltalk/squeak/pharo? I'm trying to collect the values returned by a group of methods. I don't want to have to store the methods in an instance or class variable. So I though I could add them to a protocol and in this way to "mark" them. Thanks. 回答1: In Pharo, the method you're looking for is ClassDescription>>allMethodsInCategory: : | selectors | selectors := MyClass allMethodsInCategory: #'protocol name'. To find

Which programming languages (besides Smalltalk) are image based? [closed]

心不动则不痛 提交于 2020-01-11 17:43:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . I'm really interested if someone knows a programming language that uses an image like Smalltalk... I think that is one of the greatest ides in the history of computer science.. I can not find other language besides Smalltalk that is base on an image. 回答1: Images Images are basically memory dumps. Typically a

“Dead method context” error in a function

 ̄綄美尐妖づ 提交于 2020-01-11 11:24:09
问题 I am trying to write a isBinary function that checks sent line if it has any non-printable characters (integer value outside range 0-127): isBinary := [ :sline | 'Reached isBinary fn.' displayNl. sline do: [ :char | "for each character" i := char asInteger. "convert to integer" (i < 0 | i > 127) ifTrue: [^true]. ]. "return true if found unprintable" ^false. ]. "if not found above, return false" (Directory working: '.') allFilesMatching: '*.x' do: [ :ff | ((ff name), ' : ') display. infile :=

smalltalk singleton pattern: how do I initialize the instance variables?

∥☆過路亽.° 提交于 2020-01-11 04:39:11
问题 I'm having trouble in getting the singleton pattern to initialize a instance variable in smalltalk. (here is a link to another implementation for clarification) this is what I have: new ^UniqueInstance ifNil: [UniqueInstance := self basicNew. UniqueInstance: instanceVar := Object new. ]. that last line (UniqueInstance: instanceVar := Object new.) doesn't work, but that's basically what I need to do: instantiate instanceVar as an Object before returning UniqueInstance back to the caller.

Smalltalk runtime features absent on Objective-C?

守給你的承諾、 提交于 2020-01-02 04:15:09
问题 I don't know well Smalltalk, but I know some Objective-C. And I'm interested a lot in Smalltalk. Their syntax are a lot different, but essential runtime structures (that means features) are very similar. And runtime features are supported by runtime. I thought two languages are very similar in that meaning, but there are many features on Smalltalk that absent on Objective-C runtime. For an example, thisContext that manipulates call-stack. Or non-local return that unwinds block execution. The

Is it possible to write shell command within Pharo smalltalk?

萝らか妹 提交于 2020-01-01 12:01:07
问题 Like in other programming language, is there a way of running linux shell command in Pharo smalltalk or a simple script ? I would like to have my Pharo image running a script that should be able to automate a tasks and return it to some value. I looked at almost all the documentation around and I couldn't find anything related. Maybe It does not allow such functionality. 回答1: Pharo does allow the OS interaction. The best way, in my eyes, is to use OSProcess (as MartinW already suggested).

What's the best free IDE for learning smalltalk? [closed]

怎甘沉沦 提交于 2019-12-31 20:01:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . What do you think is a good IDE for learning SmallTalk? I'll only be using it as a hobby, so it has to be free. 回答1: I think Squeak is the way to go. It has an entire smalltalk environment and is constantly updated. Its what I used for learning and is actually even a cool app in itself. 回答2: You should also

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 to add a non-Amber library with bower? (for example processing js)

浪子不回头ぞ 提交于 2019-12-25 01:52:25
问题 I have started a project with amber init and then bower install processing --save to get processing.js added. I do the initialisation with firstProcessingInstance <return Processing.instances[0]> This method is called by the instance method initialize and it worked a pre-Amber v0.13 version. How do I initialize Processing.js in Amber 0.13 and 0.14? The code of the example is here Addition after answer by Herby In version 0.13 and 0.14 a configuration file processing.amd.json has to be added