'Ola AH'; Procedures, Functions, Methods & their 'Anatomy'.


... i was taught this at Warsaw's University, when i learned Computer Sciences.

a procedure is fragment of code that can be called from other parts of the code - for code's clarity, to avoid redundancy (repetition), to use with iteration instruction, or in a recursion.

procedure does not return any value, but may take input parameters.

a function is a procedure that returns a value, of any type.

method is a procedure or a function, that is part of a Class.

for example:

public class MyClass {

  public static void main(String[] args) {
    Object arg1 = new Integer(1);
    Object arg2 = "A sample value\\n";

    int i = doSomething(arg1, arg2);

  void init() {

  int doSomething(Object arg1, Object arg2) {
     int result = 0;
     return result;

  void finalize(int intArg) {


... in an above example there are three methods; outside class definition, these would be two procedures (init & finalize), and one function (doSomething).

wherever we use word method, a procedure or function can be used as well.

a method call is this part of the code that makes program flow 'jump' to another part of the code, to the method's definition.

a method definition is part of the code where the method is elaborated - starting from a line with method's name, ending with closing bracket & an optional separator or a terminator character (;).

first line of the method's definition is called a 'method signature' - that is, the part with optional visibility & other modifiers, an optional return value type, method's name, optional parameter types & names, optional exception throw clauses, perhaps with opening bracket as well.

following parts of method definition are called a 'method body' - it's where code & perhaps return clause are contained.

... that's the anatomy of methods, procedures & functions.

'Ola AH' Programming Language.

in 'Ola AH' Programming Language methods will have following anatomy:

- optional visibility & other modifiers,
- optional return type or 'void',
- method's name,
- optional parameters tuple,
- optional throw exceptions clause, that will be similar to java's syntax for practical reasons as writing less, ... - but will be automatically converted to a tuple inside interpreter or compiler.

- opening bracket,
- instructions,
- optional return clause,
- closing bracket,
- terminator (';').

in fact a method will be an object that can be 'passed around'.

with a method object it will be possible to inspect with reflection ... for the visibility & other modifiers, a number, names & types of parameters, a return value type, exceptions thrown, method's name, instructions tree inside body.

with a method object, it will be posible to construct or change objects (class instances) dynamically (during program's run).

methods themselves will be cloneable & modifiable as well.

... see also, if You wish or need, ... : Tail Call, Selector Methods & Dynamically Created Methods in 'Ola AH' Programming Language.

No comments:

Post a Comment