OpenClonk Bugtracker - OpenClonk
View Issue Details
0001836OpenClonkEngine - C4Scriptpublic2016-10-30 11:352017-08-20 11:58
ReporterLuchs 
Assigned To 
PrioritynormalSeverityminorReproducibilityalways
StatusnewResolutionopen 
PlatformOSOS Version
Product Version 
Target Version9.0Fixed in Version 
Summary0001836: Inconsistent function binding in proplists
DescriptionInside a proplist function, when calling another function in the same proplist, the call is bound statically and does not depend on the value of "this" during runtime. However, references to the function are always resolved at runtime using the current "this" value. Consequently, a call foo() is not equivalent to Call(foo) which is confusing.

There's an example below which illustrates the issue. A real-world example is trying to use ScheduleCall() instead of Call().
Additional Informationstatic const Functions = {
  Fun1 = func() {
    Log("Fun1");
    Fun2("direct call"); // always works
    Call(Functions.Fun2, "Call(Function.Fun2)"); // always works
    Call(Fun2, "Call(Fun2)"); // doesn't work, should be equivalent to direct call

    this->Fun2("call on this"); // doesn't work, okay
    Call(this.Fun2, "Call(this.Fun2)"); // doesn't work, okay
  },

  Fun2 = func(string how) {
    Log("Fun2: %s", how);
  },
};

func Main() {
  Functions->Fun1();
  Call(Functions.Fun1); // call with different "this"
}
TagsNo tags attached.
Attached Files

There are no notes attached to this issue.

Issue History
2016-10-30 11:35LuchsNew Issue
2017-08-05 13:58MaikelTarget Version => 8.0
2017-08-20 11:58ZapperTarget Version8.0 => 9.0