smalltalk

Can operators in Smalltalk be overloaded?

五迷三道 提交于 2019-11-30 14:33:10
Is it possible to overload operators in Smalltalk? I am looking for tutorials/examples. Thanks. Method overloading is not possible in Smalltalk. Instead, a combination of method overriding and a technique called double dispatch is used to implement the same behavior as operator overloading in other languages. You can find an example implementation in the mathematical operators +,*,/,- (which are binary messages in Smalltalk). Here is the idea: the implementation of Integer>>+ sends a message #addWithInteger: to its argument. The implementation of #addWithInteger: is implemented on each

How can I easily change to native fonts in Smalltalk Squeak/Pharo

怎甘沉沦 提交于 2019-11-30 13:50:49
问题 With every new Squeak/Pharo image, I immediately change the fonts to some native version. It is a lot of mouseclicks and I want to script the process. 回答1: The above answer might be outdated by now, at least it doesn't work with my 3.10 image. so, I use this: defaultFont := LogicalFont familyName: 'Geneva' pointSize: 10 emphasis:0 . codeFont := LogicalFont familyName: 'Monaco' pointSize: 10 emphasis:0. Preferences setCodeFontTo: codeFont. Preferences setWindowTitleFontTo: defaultFont.

Is Seaside still a valid option?

≯℡__Kan透↙ 提交于 2019-11-30 12:04:31
问题 Seaside just released a release candidate for the upcoming 3.0 version, so it appeared on my radar again. As I'm currently pondering what web framework to use for a future project, I wonder whether it's something to consider. Alas, most of the publicity for Seaside is from '07, which is probably one or two generations for the web. So I'm hoping that the community here can answer some questions Continuation-based frameworks were pretty great when most of your workflow was mostly in HTML, e.g.

Python 闭包

∥☆過路亽.° 提交于 2019-11-30 11:08:56
函数create_y与变量a,b构成闭包。在创建闭包的时候,我们通过test的参数a,b说明了这两个变量的取值,这样,我们就确定了函数的最终形式(y = x + 2和y = 2x + 4)。我们只需要变换参数a,b,就可以获得不同的直线表达函数。由此,我们可以看到,闭包也具有提高代码可复用性的作用。 如果没有闭包,我们需要每次创建直线函数的时候同时说明a,b,x。这样,我们就需要更多的参数传递,也减少了代码的可移植性。 关于闭包,维基百科的定义如下: 在计算机科学中,闭包(Closure)是词法闭包(Lexical Closure)的简称,是引用了自由变量的函数。这个被引用的自由变量将和这个函数一同存在,即使已经离开了创造它的环境也不例外。所以,有另一种说法认为闭包是由函数和与其相关的引用环境组合而成的实体。 百度百科: 闭包是可以包含自由(未绑定到特定对象)变量的代码块;这些变量不是在这个代码块内或者任何全局上下文中定义的,而是在定义代码块的环境中定义(局部变量)。“闭包” 一词来源于以下两者的结合:要执行的代码块(由于自由变量被包含在代码块中,这些自由变量以及它们引用的对象没有被释放)和为自由变量提供绑定的计算环境(作用域)。在 Scala、Scheme、Common Lisp、Smalltalk、Groovy、JavaScript、Ruby、 Python和Lua

Variable types in smalltalk

扶醉桌前 提交于 2019-11-30 09:21:37
问题 I need help understanding the usage and the difference of variables in Smalltalk. What is the difference and the usage of each variable in the given code below? Object subclass: #MyClass instanceVariableNames: 'x' classVariableNames: 'Yy' poolDictionaries: '' category: 'helpMe' MyClass class instanceVariableNames: 'zzz' 回答1: An instance variable ( x ) is a variable that is local to an instance. Neither the class nor any other instance can access that variable. A class variable ( Yy ) is local

How can I easily change to native fonts in Smalltalk Squeak/Pharo

╄→尐↘猪︶ㄣ 提交于 2019-11-30 08:38:28
With every new Squeak/Pharo image, I immediately change the fonts to some native version. It is a lot of mouseclicks and I want to script the process. The above answer might be outdated by now, at least it doesn't work with my 3.10 image. so, I use this: defaultFont := LogicalFont familyName: 'Geneva' pointSize: 10 emphasis:0 . codeFont := LogicalFont familyName: 'Monaco' pointSize: 10 emphasis:0. Preferences setCodeFontTo: codeFont. Preferences setWindowTitleFontTo: defaultFont. Preferences setButtonFontTo: defaultFont. Preferences setListFontTo: defaultFont. Preferences setMenuFontTo:

Why is smalltalk not a functional programming language?

独自空忆成欢 提交于 2019-11-30 06:26:17
问题 With the renewed interest in functional programming languages, I've seen some similitudes between Smalltalk and FPL, namely closures ( BlockClosures in Smalltalk ) Yet, Smalltalk is not a FPL? What would be needed to consider it as such? 回答1: Programming with the Object Oriented paradigm is creating a program by identifying and modeling the Problem Domain Entities as objects, and then make them collaborate between themselves to solve each problem instance. Programming with the Functional

Best way to start with smalltalk in a windows environment (win 7) [closed]

馋奶兔 提交于 2019-11-30 03:12:19
I am a c# developer and most of my friends are much smarter than me, and they laugh at me and start to swear at me in smalltalk. I want to learn this so that I might better be insulted at their insults... and maybe learn a thing or two in the process. So, what is the best place to start with regard to smalltalk in a windows environment? The best current free Smalltalk is probably Squeak . This currently out-performs its near relative Pharo , at least on my ancient box, but you should really take a look at both of them. The big problem with Smalltalk is that there are no really high-quality

Is Seaside still a valid option?

筅森魡賤 提交于 2019-11-30 01:22:23
Seaside just released a release candidate for the upcoming 3.0 version, so it appeared on my radar again. As I'm currently pondering what web framework to use for a future project, I wonder whether it's something to consider. Alas, most of the publicity for Seaside is from '07, which is probably one or two generations for the web. So I'm hoping that the community here can answer some questions Continuation-based frameworks were pretty great when most of your workflow was mostly in HTML, e.g. form submits. For today's JavaScript-heavy environments, that hardly seems worthwhile anymore. Is

Variable types in smalltalk

我的梦境 提交于 2019-11-29 15:06:11
I need help understanding the usage and the difference of variables in Smalltalk. What is the difference and the usage of each variable in the given code below? Object subclass: #MyClass instanceVariableNames: 'x' classVariableNames: 'Yy' poolDictionaries: '' category: 'helpMe' MyClass class instanceVariableNames: 'zzz' An instance variable ( x ) is a variable that is local to an instance. Neither the class nor any other instance can access that variable. A class variable ( Yy ) is local to a class, all its instances, all subclasses and all subinstances (so the entire hierarchy). Any subclass