makeNewObject
- function
- The common way to use a new object expression is to specify a "factory object", as in the following example:
put new Person with (name:"Jenny", age:6) into daughter
This example will look for an object named "Person" and send that object a makeNewObject
function message with the initial properties as a parameter. If the object has a makeNewObject handler, it should create and return a new object. If not, SenseTalk's built-in makeNewObject function will be called, which will create a new object helped by the "factory" object (Person, in this case), set any properties of that object that were supplied in the new expression (name and age in this example), and then send the object an "initialize" message. The effect of the built in behavior is the same as this makeNewObject function:
function makeNewObject initialProperties
add properties of me to initialProperties
get new object with initialProperties helped by me
send "initialize" to it
return it
end makeNewObject
• If a different behavior is needed, simply write a custom makeNewObject function.