Often the most convenient way to allocate a new object is to use the namespace-colon syntax discussed in the pervious section. For example:
(java.util.Vector:new 20)
Constructs a new object instance of the specified
type
, which must be either ajava.lang.Class
or a<gnu.bytecode.ClassType>
.The
args ...
are passed to the constructor of the class type. If there is no applicable constructor, and theargs ...
consist of a set of (keyword
,value
)-pairs, then the default constructor is called, and each (keyword
,value
)-pair is used to set the correspdong slot of the result, as if by:(slot-set!
.result
keyword
value
)For example, the following are all equivalent:
(set! p (make <java.awt.Point> 3 4)) (set! p (make <java.awt.Point> y: 4 x: 3)) (set! p (make <java.awt.Point>)) (slot-set! p 'x 3) (set! (slot-ref p 'y) 4)