6.25.3.9 Dividing classes

You may want to do the definition of methods separate from the definition of the class, its selectors, fields, and instance variables, i.e., separate the implementation from the definition. You can do this in the following way:

graphical class
  inst-value radius
end-class circle

... \ do some other stuff

circle methods \ now we are ready

m: ( x y circle -- )
  radius draw-circle ;m
overrides draw

m: ( n-radius circle -- )
  [to-inst] radius ;m
overrides construct

end-methods

You can use several methods...end-methods sections. The only things you can do to the class in these sections are: defining methods, and overriding the class’s selectors. You must not define new selectors or fields.

Note that you often have to override a selector before using it. In particular, you usually have to override construct with a new method before you can invoke heap-new and friends. E.g., you must not create a circle before the overrides construct sequence in the example above.