You are on page 1of 3

_for i _over range(2,100

_if((i _mod 2)=0)
write("even number:")
write("odd number")

} :superclass


$ _method mr.sub(a,b,c)
_return (a-b-c)
MagikSF> f.write("dfvsdCV")
MagikSF> f.close()
_method sri_rr.add(a,b)

MagikSF> gis_program_manager.databases

_for i _over c.fast_elements()

The same method name can be used for two or more object classes, and the method
for each object class may define different behaviour.
For example, you might define a method named area on an object class rectangle,
and a different method with the same name on class circle. If each object has
knowledge of its own dimensions, the method defined on rectangle implements
width * height, while the method defined on circle implements p * radius squared
You could then use expressions like the following to get an appropriate result:
MagikSF> a_rectangle.area
MagikSF> a_circle.area
This example illustrates polymorphism

Slotted objects have named fields, called slots, which can refer to any Magik ob
This is the most common format, and almost all the core classes are slotted,
including set, hash_table, external_text_input_stream and so on.
Some classes of slotted object behave as though they are indexed. For example, t
class rope behaves like a simple_vector except that it can change in length. Obj
of this class have two slots one slot refers to the current length and the other r
to a simple_vector in which the actual contents are maintained.
---------------------------------------------------------------------------------------debug_print_on() on each argument. For example:
MagikSF> x << 3
MagikSF> y << 4.5
MagikSF> show(x,y)
3 4.500

MagikSF> write(x,y)
MagikSF> print(x,y)
See Section 10.1 for more details
> _for i _over sv.elements()
_if (i = 12)
write("mini num:",+i)
_elif (i = 98)
write("max num ",+i)
_else write("not found")
mini num:12
not found
not found
not found
max num 98
not found
not found
----------------------------------------------------------------------------------The _clone creates a physical copy of the person object.
The _super statement allows objects to invoke an implementation of a method on t
he parent exemplar.
Objects can reference themselves using the _self statement. An object's slots a
re accessed and assigned using a dot notation.
Methods that are not part of the public interface of the object can be marked pr
ivate using the _private statement.
Private methods can only be called by _self, _super and _clone.
Optional arguments can be declared using the _optional statement.
Optional arguments that are not passed are assigned by Magik to the special obje
ct _unset (the equivalent of null).
The _gather statement can be used to declare a list of optional arguments.