Create new object (synchronous constructor)
(newobject)
newobject [instructions]
(newobject [instructions] expression1 expression2 ...)
newobject function
(newobject function expression1 expression2 ...)
(newo)
newo [instructions]
(newo [instructions] expression1 expression2 ...)
newo function
(newo function expression1 expression2 ...)
Creates new object. A list of instructions or a function passed as an argument is used as
constructor of the new object. The turtle/object which called the newobject
instruction is waiting for the new object's constructor completion before it continues its own code. The
constructor's arguments can be passed as optional expressions.
Object in POOL is a simplified version of a turtle. Objects do not have graphics representation and do not
handle events related to graphics (e.g. mouse clicks). Objects use less memory, they are created faster and
also execute their tasks faster than turtles.
Example 1:
"t := (newo)
print who
print children
print parent @ :t
print who @ :t
Output:
first
[o1]
first
o1
Example 2:
"t := newo [
"x := 10
print who
]
print :x @ :t
Output:
o1
10
Example 3:
to model :x
to fn
op :variable^2
end
let "variable :x
(print who :x)
end
"t := (newo $model 5)
print fn @ :t
Output:
model1 5
25
See also:
Turtle - object
Synchronization of multiple objects
Table of content