GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  COPY (n)

NAME

oo::copy - create copies of objects and classes

CONTENTS

Synopsis
Description
Examples
Keywords

SYNOPSIS

package require TclOO

oo::copy sourceObject ?targetObject?


   








\L’|0u-1v’\l’75u+3n_’\L’0u+1v-0u’\l’|0u-1.5n_’



\L’|0u-1v’\L’0u+1v-0u’\l’|0u-1.5n_’





DESCRIPTION

The oo::copy command creates a copy of an object or class. It takes the name of the object or class to be copied, sourceObject, and optionally the name of the object or class to create, targetObject, which will be resolved relative to the current namespace if not an absolute qualified name. If targetObject is omitted, a new name is chosen. The copied object will be of the same class as the source object, and will have all its per-object methods copied. If it is a class, it will also have all the class methods in the class copied, but it will not have any of its instances copied.

After the targetObject has been created and all definitions of its configuration (e.g., methods, filters, mixins) copied, the <cloned> method of targetObject will be invoked, to allow for the customization of the created object. The only argument given will be sourceObject. The default implementation of this method (in oo::object) just copies the procedures and variables in the namespace of sourceObject to the namespace of targetObject. If this method call does not return a result that is successful (i.e., an error or other kind of exception) then the targetObject will be deleted and an error returned.

The result of this command will be the fully-qualified name of the new object or class.

EXAMPLES

This example creates an object, copies it, modifies the source object, and then demonstrates that the copied object is indeed a copy.


oo::object create src
oo::objdefine src method msg {} {puts foo}
oo::copy src dst
oo::objdefine src method msg {} {puts bar}
src msg              -> prints "bar"
dst msg              -> prints "foo"


SEE ALSO

oo::class(n), oo::define(n), oo::object(n)

KEYWORDS

clone, copy, duplication, object

Search for    or go to Top of page |  Section n |  Main Index


TclOO COPY (n) 0.1

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.