Call an object method: Difference between revisions

Content added Content deleted
Line 62: Line 62:
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).PointerMethod(myPointer, someParameter)
(*Foo).ValueMethod(myPointer, someParameter)</lang>
(*Foo).ValueMethod(myPointer, someParameter)</lang>

==Icon and {{header|Unicon}}==
In Unicon all procedures and methods are dynamically invoked at run-time. The normal method of invoking a method is with instances of its class. While it is technically possible to call a method without having an instance it requires knowledge of the underlying translation of methods and classes to procedures and is somewhat unusual.
<lang Icon>procedure main()

foo_m1() # equivalent of class method, not normally used
bar := foo() # create instance
bar.m2() # call method m2 with self=bar
end


class foo(cp1,cp2)
method m1(m1p1,m1p2)
local ml1
static ms1
ml1 := m1p1
# do something
return
end
method m2(m2p1)
# do something else
return
end
initially
L := [cp1]
end</lang>
Note: Icon cannot translate code with objects. It may be possible for Icon to translate code preprocessed by Unicon if no other Unicon extensions are used.


=={{header|J}}==
=={{header|J}}==