6.3 Creating Objects shows three separate methods for creating objects:
(make-object class init-v ...) → object?
(new class-expr (id by-name-expr) ...)
(instantiate class-expr (by-pos-expr ...) (id by-name-expr) ...)
If I'm reading this right, there are three differences between these methods:
A) make-object
uses all positional initialization, new
uses all named initialization, and instantiate
allows you to mix the two styles
B) make-object
is a procedure, the other two are syntactic forms
C) make-object
takes a class as its first argument while the other two take class expressions.
This leaves me with some questions:
- Are there other differences?
- Should I prefer one approach over another?
- What is the difference between a 'class' and a 'class expression' in this context? My understanding is that when an expression is validated the system works from the inside out, so by the time
make-object
ornew
are being evaluated there should be a class value sitting in that first slot.
In regular code I tend to prefer keywords for anything that has more than 2-3 arguments, so I instinctively lean away from make-object
but maybe there's a reason not to.