What is a "member function"?

#1

If I have the following types:

type A {
foo: member function(arg1: string) : string
}

type B extends A {
@py(env=‘server’)
foo: ~
}

What does “member function” mean?

0 Likes

#2

member functions are called on INSTANCES of the type on which they are declared. e.g.

A.make().foo(‘hello’) will call function ‘foo’ on the instance of type A. If foo is implemented in js, then ‘this’ will be the instance of type A, not type A itself.

if B mixes A, then B.foo is a member function also, and must be called as B.make().foo()

0 Likes

#3

I just learned that there is a “Method Declaration” In-Depth document on the c3server (e.g. http://localhost:8080/api/1/c3/c3/documentation/topic/methods , replace http://localhost:8080 with your vanity URL) which explains a lot of the goodies about keywords used on methods (and types), including the member keyword.

2 Likes