copy



copy

NAME
SYNOPSIS
DESCRIPTION
EXAMPLES
SEE ALSO
KEYWORDS

___________________________

NAME

oo::copy − create copies of objects and classes

SYNOPSIS

package require TclOO

oo::copy sourceObject ?targetObject? ___________________________

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 customization of │ the created object such as installing related variable traces. 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 the oo::copy 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




More Linux Commands

manpages/audit_encode_nv_string.3.html
audit_encode_nv_string(3) - encode a name/value pair in a st
This function is used to encode a name/value pair. This should be used on any field being logged that potentially contains a space, a double-quote, or a control

manpages/gnutls_anon_free_client_credentials.3.html
gnutls_anon_free_client_credentials(3) - API function.......
gnutls_anon_free_client_credentials.3 - This structure is complex enough to manipulate directly thus this helper function is provided in order to free (dealloca

manpages/sysctl.2.html
sysctl(2) - read/write system parameters - Linux man page...
Do not use this system call! See NOTES. The _sysctl() call reads and/or writes kernel parameters. For example, the hostname, or the maximum number of open files

manpages/gcjh.1.html
gcjh(1) - - generate header files from Java class files.....
The gcjh program is used to generate header files from class files. It can generate both CNI and JNI header files, as well as stub implementation files which ca

manpages/hexdump.1.html
hexdump(1) - display file contents in ascii, decimal, hexade
The hexdump utility is a filter which displays the specified files, or standard input if no files are specified, in a user-specified format. OPTIONS Below, the

manpages/ldap_objectclass2name.3.html
ldap_objectclass2name(3) - Schema definition handling routin
These routines are used to parse schema definitions in the syntax defined in RFC 4512 into structs and handle these structs. These routines handle four kinds of

manpages/XpGetImageResolution.3x.html
XpGetImageResolution(3x) - Gets the current image resolution
XpGetImageResolution returns the current image resolution for the specified print context. A value of zero means the resolution automatically tracks the printer

manpages/colrm.1.html
colrm(1) - remove columns from a file - Linux manual page...
colrm removes selected columns from a file. Input is taken from standard input. Output is sent to standard output. If called with one parameter the columns of e

manpages/vgcfgrestore.8.html
vgcfgrestore(8) - restore volume group descriptor area......
vgcfgrestore allows you to restore the metadata of VolumeGroupName from a text backup file produced by vgcfgbackup. You can specify a backup file with --file. I

manpages/su.1.html
su(1) - run a shell with substitute user and group IDs......
su allows to run commands with a substitute user and group ID. When called without arguments, su defaults to running an interactive shell as root. For backward

manpages/hdestroy.3.html
hdestroy(3) - hash table management - Linux manual page.....
The three functions hcreate(), hsearch(), and hdestroy() allow the caller to create and manage a hash search table containing entries consisting of a key (a str

manpages/keyctl_instantiate_iov.3.html
keyctl_instantiate_iov(3) - Instantiate a key from segmented
keyctl_assume_authority() assumes the authority for the calling thread to deal with and instantiate the specified uninstantiated key. The calling thread must ha





We can't live, work or learn in freedom unless the software we use is free.