do g(5,7) // calls method g of class Foo (on this object)
In such a code, how can we be sure that there was an object constructed/created before? If there is not any object or there is an object in different class, what is the expected result ?
Jack does not do any checking that the programmer correctly called f(). It is up to the programmer to ensure that they supplied the correct type of object.
function void main()
var Foo thing1;
var Bar thing2;
var Bar badness;
do thing1.f(); // calls Foo.f() with this = 0, will likely crash
let thing1 = Foo.new();
do thing1.f(); // calls Foo.f() with this = the new Foo object
let thing2 = Bar.new();
do thing2.f(); // calls Bar.f() with this = the new Bar object
let thing2 = thing1;
do thing2.f(); // calls Bar.f() with this = a Foo object, will likely crash
Neither of the errors in the above code will be detected by the compiler.