Rev 68948 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/methods/man/className.Rd% Part of the R package, https://www.R-project.org% Copyright 2011-2 R Core Team% Distributed under GPL 2 or later\name{className}\alias{className}\alias{multipleClasses}\alias{className-class}\title{Class names including the corresponding package}\description{The function \code{className()} generates avalid references to a class, including the name of the packagecontaining the class definition. The object returned, from class \code{"className"}, is theunambiguous way to refer to a class, for example when calling\code{\link{setMethod}}, just in case multiple definitions of theclass exist.Function\code{"multipleClasses"} returns information about multipledefinitions of classes with thesame name from different packages.}\usage{className(class, package)multipleClasses(details = FALSE)}\arguments{\item{class, package}{The character string name of a class and, optionally, of the packageto which it belongs. If argument \code{package} is missing and the\code{class} argument has a package slot, that is used (inparticular, passing in an object from class \code{"className"} returnsitself in this case, but changes the package slot if the secondargument is supplied).If there is no package argument or slot, adefinition for the class must exist and will be used to define thepackage. If there are multiple definitions, one will be chosen and awarning printed giving the other possibilities.}\item{details}{If \code{FALSE}, the default, \code{multipleClasses()} returns acharacter vector of those classes currently known with multipledefinitions.If \code{TRUE}, a named list of those class definitions is returned.Each element of the list is itself a list of the corresponding classdefinitions, with the package names as the names of the list. Notethat identical class definitions will not be considered\dQuote{multiple} definitions (see the discussion of the details below).}}\details{The table of class definitions used internally can maintain multipledefinitions for classes with the same name but coming from differentpackages.If identical class definitions are encountered, only one classdefinition is kept; this occurs most often with S3 classes that havebeen specified in calls to \code{\link{setOldClass}}. For trueclasses, multiple class definitions are unavoidable in general if twopackages happen to have used the same name, independently.Overriding a class definition in another package with the same name deliberately is usually a badidea.Although \R attempts to keep and use the two definitions (as ofversion 2.14.0), ambiguities are always possible. It is moresensible to define a new class that extends an existing class but hasa different name.}\value{A call to \code{className()} returns an object from class\code{"className"}.A call to \code{multipleClasses()} returns either a charactervector or a named list of class definitions. In either case, testingthe length of the returned value for being greater than \code{0} is acheck for the existence of multiply defined classes.}\section{Objects from the Class}{The class \code{"className"} extends \code{"character"} and has a slot\code{"package"}, also of class \code{"character"}.}\examples{\dontrun{className("vector") # will be found, from package "methods"className("vector", "magic") # OK, even though the class doesn't existclassName("An unknown class") # Will cause an error}}\keyword{ classes }\keyword{ programming }