[Grace-core] [less important] Cloning as a Factory method

James Noble kjx at ecs.vuw.ac.nz
Fri Mar 8 22:29:28 PST 2013


Can the clone primitive count as a factory method?

Can we get stuff like this

method clone is factory {
  def other is factory = clone
  other.rep = rep.clone
  // bunch of other stuff
  return other 
}

to also count as a factory method?   

Is returning an object that didn't previously exist enough of a condition for all this to work? 

Note what the semantics must be here: if clone is a factory method, then clone
doesn't create a new object --- it does its clone **into the object under construction**
that was passed in as the extra implicit parameter.

I think this works too.

I don't know if I like that or not.

James


More information about the Grace-core mailing list