Create new turtle (synchronous constructor)

(newturtle)
newturtle [instructions]
(newturtle [instructions] expression1 expression2 ...)
newturtle function
(newturtle function expression1 expression2 ...)

(newt)
newt [instructions]
(newt [instructions] expression1 expression2 ...)
newt function
(newt function expression1 expression2 ...)

Creates new turtle. A list of instructions or a function passed as an argument is used as constructor of the new turtle. The turtle which called the newturtle instruction is waiting for the new turtle's constructor completion before it continues its own code. The constructor's arguments can be passed as optional expressions.

Example 1:

"t := (newt)
print who
print children
print parent @ :t
print who @ :t

Output:

first
[t1]
first
t1

Example 2:

"t := newt [
  "x := 10
  print who
]
print :x @ :t

Output:

t1
10

Example 3:

to model :x
  to fn
    op :variable^2
  end
  let "variable :x
  (print who :x)
end

"t := (newt $model 5)
print fn @ :t

Output:

model1 5
25

See also:

Turtle - object

Table of content