Next: Documentation, Previous: Cautions, Up: Methods [Index]
__c_arg__
Treat the next method argument as a C argument. See Method functions.
classMethod
The classMethod
keyword declares a method, as described
above.
classVariable
Adds a class variable definition to a class. This method needs to be used globally, when a class is declared. The syntax is:
parent_class classVariable name [native_class|typecast_expr] [initial_value] [docstring] ;
For example:
FileStream class ReadFileStream; ... ReadFileStream classVariable stdinStream Symbol 0x0;
The value of initial_value can be either a constant or an expression that evaluates to a constant.
Ctalk can also translate a typecast into a native class for the
variable. Also refer to the entry for instanceVariable
, below.
See InstanceVariableKeyword.
Similarly, the docString element is also optional. See VariableDocStrings.
eval
Do not try to evaluate the following statement until run time. Methods can use this keyword if they need to wait until run time to determine an receiver’s class and are not able to alias the object or otherwise inform the front end of the receiver’s class before the program is run.
instanceMethod
The instanceMethod
keyword declares a method, as described
above.
instanceVariable
Adds an instance variable definition to a class. This method needs be used when the class is declared. The syntax is:
parent_class instanceVariable name [native_class|typecast_expr] [initial_value] [docString] ;
For example:
FileStream class ReadFileStream; ReadFileStream instanceVariable pos LongInteger 0L;
The value of initial_value can be either a constant or an expression that evaluates to a constant.
You can also use a typecast in place of the variable’s native_class. Ctalk can translate most builtin C types or typedefs to a class, but for less common data types, Ctalk will translate a pointer to the type as a Symbol object.
Similarly, the docString element is also optional. See VariableDocStrings.
Note that the instanceVariable
method does not create any
variables. Ctalk only creates instance variables for each object when
it receives a constructor message (e.g., new
) by a program.
noMethodInit
Do not include method initialization code for the method. See Method functions.
require
Require a class to be loaded before any other classes or methods.
returnObjectClass
Set the return class of a method to the argument if it is different than the receiver class. See Return values.
self
Return the method’s receiver object. In version
0.66 2021-02-02, you can also use self
in arguments as a
synonym for the receiver of the statement, as in this example.
String new path; path = "/home/user/joe"; printf ("%s", path subString 1, self length - 1);
The use of self
in method arguments is experimental in version
0.66 2021-02-02, and it should be used with caution.
super
The keyword super
has two different meanings. It can
modify a method, as in the following example.
MyReceiverClass super new instanceObject;
super
can also represent the receiver’s superclass
object, so it can appear as a receiver, as in this example.
return super new checksum;
Next: Documentation, Previous: Cautions, Up: Methods [Index]