小编Jer*_*ees的帖子

Smalltalk初始化变量

在Java和C++等语言中,我们为构造函数提供参数.

你是如何在Pharo Smalltalk中做到这一点的?

我想要类似的东西

|aColor|
aColor = Color new 'red'.
Run Code Online (Sandbox Code Playgroud)

或者这是不好的做法,我应该一直这样做

|aColor|
aColor = Color new.
aColor name:= red.d
Run Code Online (Sandbox Code Playgroud)

smalltalk pharo

8
推荐指数
1
解决办法
4579
查看次数

有没有办法修改观察值而不触发Polymer中的观察者回调

就像标题所说的那样.有没有办法在不触发Polymer中的观察者回调的情况下修改观察值?

例如

Polymer({
        is: 'my-component',

        properties: {
            aValue: {
                type: Number,
                value: 0,
                observer: '_valueChanged',
                notify: true
            },
            ref: {
                type: Object,
                computed: '_computeRef(channel, channelNumber)'
            }
        },

        _computeRef: function(channel, channelNumber) {

            var ref = new Firebase("/*link*/");
            ref.on("child_changed", function(data) {
               this.aValue.setWithoutCallingObserver(data.val());
            }.bind(this));

            return ref;
        },

        _valueChanged: function() {
            var message = { aValue: this.aValue };
            if (this.ref) {
                this.ref.set(message);
            }
        }

    });
Run Code Online (Sandbox Code Playgroud)

这将是有用的,因为现在我遇到以下情况中的滞后:

  1. 适应aValue第三方应用程序
  2. Firebase会更新所有客户端
  3. .on回调设置值并触发观察者回调
  4. 导致.set到firebase
  5. 回到2.

更新:问题与firebase无关.我相信解决方案是控制如何将更新应用于Polymer中的观察值.部分原因是对firebase商店中的值的更改也可以由第3方(不一定是Web)应用程序进行.

polymer object.observe

7
推荐指数
1
解决办法
907
查看次数

如何解决 SAXException: Invalid element in

我尝试通过以下方式从网络服务中获取结果。

List result = new Vector();
LibrarySearchRequest request = new LibrarySearchRequest(queryString);
LibrarySearchServicePortTypeProxy proxy = 
                                new LibrarySearchServicePortTypeProxy();
LibrarySearchServicePortType port = proxy.getLibrarySearchServicePortType();
LibrarySearchResponse response = port.process(request);
librarysearch.soft.Book[] books = response.getBooks();
Run Code Online (Sandbox Code Playgroud)

当我这样做时,我得到以下异常(堆栈跟踪):

org.xml.sax.SAXException: Invalid element in librarysearch.soft.Book - book
at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
at org.apache.axis.client.Call.invoke(Call.java:2467)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
at librarysearch.soft.LibrarySearchServiceSOAP11BindingStub.process(LibrarySearchServiceSOAP11BindingStub.java:180)
at softarch.portal.db.ws.WS_RegularDatabase.findRecords(WS_RegularDatabase.java:44)
at softarch.portal.db.test.TestWSRegularDatabase.main(TestWSRegularDatabase.java:39)

The regular database has caught an unexpected exception: ; nested exception is: 
org.xml.sax.SAXException: Invalid element in librarysearch.soft.Book - book
Run Code Online (Sandbox Code Playgroud)

我读到这个问题可能是由于从 …

java axis wsdl web-services sax

5
推荐指数
1
解决办法
3万
查看次数

c ++继承和构造函数

class A {
public:
      A(int i): data(i) {cout << "A::A(" << i << ")" << endl;}
      A(const char* s): data(0) { cout << "A::A(" << s << ")"<< endl;}
      ~A() { cout << "A::~A()" << endl;}
private:
int data;
};

class B:public A {
public:
    B(const A& a): A(a){ std::cout << "B::B(const A& a)" << std::endl;}
     ~B() { std::cout << "B::~B()" << std::endl;}
};

int main() {
    B b0(0);
    B b1("abc");
return 0;
}
Run Code Online (Sandbox Code Playgroud)

非常简单,有人可以解释为什么输出是:

 A::A(0)
 B::B(const A& a)
 A::~A() …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance constructor

3
推荐指数
1
解决办法
355
查看次数

在haskell中翻译while(x <SomeTreshold)

如果某个变量小于某个阈值,那么当实现在while循环的每次迭代中检查的算法时,它会发生很多.

在命令式语言中,它看起来像:

 while ( x < TRESHOLD ) {
      x = usefullStuff();
 }
Run Code Online (Sandbox Code Playgroud)

当然有用的东西以某种方式影响x ......

如何将此构造转换为利用函数式编程范例的haskell?

haskell

3
推荐指数
2
解决办法
318
查看次数

更新Matrix Haskell

我将通过列表[[a]]表示项目中的矩阵

  • 这是一个好主意还是我应该更好地使用数组?

  • 如何使用索引(i,j)更改位置元素

haskell functional-programming matrix

1
推荐指数
2
解决办法
827
查看次数

smalltalk中的ad hoc多态性

如果不使用if-test或者是针对类型检查的测试,如何在smalltalk中完成?

例如 :

function Add( x, y : Integer ) : Integer;
begin
    Add := x + y
end;

function Add( s, t : String ) : String;
begin
    Add := Concat( s, t )
end;
Run Code Online (Sandbox Code Playgroud)

smalltalk

1
推荐指数
1
解决办法
225
查看次数