Hi! I think that there are no mechanism in S4 to make slots "private". But you as a package developer can of course provide accessor functions to a public slot anyway and use slot(myslot,value,check=FALSE) to switch of the function checkSlotAssignment function and speed up your code. This is how I interpretation of this text of John Chambers. Sincerely Eryk *********** REPLY SEPARATOR *********** On 5/27/2004 at 2:01 PM Matthias Kohl wrote:>Hi all, > >in the help for RClassUtils I found the expression "privileged slots" in >function "checkSlotAssignment" with the explanation: > >/privileged slots (those that can only be set by accesor functions >defined along with the class itself)/ > >I thought all slots of a (not private) class can be a accessed by a user >via the @ Operator. >Is there a way to make a single slot of a class (not the whole class) >private, so that you can access this slot only via an accessor function >(not via @)? > >Thanks, for your help >Matthias > >______________________________________________ >R-help at stat.math.ethz.ch mailing list >https://www.stat.math.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlDipl. bio-chem. Eryk Witold Wolski @ MPI-Moleculare Genetic Ihnestrasse 63-73 14195 Berlin 'v' tel: 0049-30-83875219 / \ mail: wolski at molgen.mpg.de ---W-W---- http://www.molgen.mpg.de/~wolski
Hi all, in the help for RClassUtils I found the expression "privileged slots" in function "checkSlotAssignment" with the explanation: /privileged slots (those that can only be set by accesor functions defined along with the class itself)/ I thought all slots of a (not private) class can be a accessed by a user via the @ Operator. Is there a way to make a single slot of a class (not the whole class) private, so that you can access this slot only via an accessor function (not via @)? Thanks, for your help Matthias
>>>>> "Matthias" == Matthias Kohl <Matthias.Kohl at uni-bayreuth.de> >>>>> on Thu, 27 May 2004 14:01:51 +0100 writes:Matthias> Hi all, in the help for RClassUtils I found the Matthias> expression "privileged slots" in function Matthias> "checkSlotAssignment" with the explanation: Matthias> /privileged slots (those that can only be set by Matthias> accesor functions defined along with the class Matthias> itself)/ RClassUtils ??? > help.search("RClassUtils") No help files found with alias or concept or title matching 'RClassUtils' using fuzzy matching. ----- So I guess that's not something in a standard R document. You should rather keep to the 'official documentation' ... Matthias> I thought all slots of a (not private) class can Matthias> be a accessed by a user via the @ Operator. I tend to agree with your thoughts... Matthias> Is there a way to make a single slot of a class (not Matthias> the whole class) private, so that you can access Matthias> this slot only via an accessor function (not via @)? I'd rather guess not. Matthias> Thanks, for your help Matthias Martin
(I'm picking up this thread after it started, so may be unaware of some contributions).> > Matthias> Martin Maechler schrieb: > >>>>>>> "Matthias" == Matthias Kohl > >>>>>>> <Matthias.Kohl at uni-bayreuth.de> on Thu, 27 May 2004 > >>>>>>> 14:01:51 +0100 writes: > >>>>>>> > >>>>>>> > >> > Matthias> Hi all, in the help for RClassUtils I found the > Matthias> expression "privileged slots" in function > Matthias> "checkSlotAssignment" with the explanation: > >> > Matthias> /privileged slots (those that can only be set by > Matthias> accesor functions defined along with the class > Matthias> itself)/ > >> > >> > >> RClassUtils ??? > >> > >> > help.search("RClassUtils") > >> > >> > Matthias> your right, sorry > > Matthias> but, at least a R Site search in "Functions" gives > Matthias> me one match: "Utilities for Managing Class > Matthias> Definitions" which hast the "title": > Matthias> RClassUtils{methods} R Documentation > > >> No help files found with alias or concept or title > >> matching 'RClassUtils' using fuzzy matching. > >> > >> ----- > >> > >> So I guess that's not something in a standard R document. > >> You should rather keep to the 'official documentation' > >> ... > >> > >> > Matthias> I thought this is a official documentation ...Not really. It's internal documentation, not meant to be visible. So it doesn't get as much attention as perhaps it should. Better to use the public documentation (see below).> > Matthias> I thought all slots of a (not private) class can > Matthias> be a accessed by a user via the @ Operator. > >> I tend to agree with your thoughts... > >> > Matthias> Is there a way to make a single slot of a class > Matthias> (not the whole class) private, so that you can > Matthias> access this slot only via an accessor function > Matthias> (not via @)? > >> I'd rather guess not.The current situation is that slot access is just done by slot name, so anything that can be found is allowed. In the original design of S4 classes, there was provision for specifying access when setClass was called. This was never implemented and in fact is not in the Programming with Data book, as far as I know. The access= argument was retained in setClass for portability, but the "official" documentation in ?setClass says: access: Access list for the class. Saved in the definition, but not currently used. That's the safer place to look for information. It is possible, but not very likely, that access lists might be revived if the underlying mechansim for slot access is changed. John Chambers> >> > Matthias> Thanks, for your help Matthias > >> Martin > > _______________________________________________ > R-core list: https://www.stat.math.ethz.ch/mailman/listinfo/r-core-- John M. Chambers jmc at bell-labs.com Bell Labs, Lucent Technologies office: (908)582-2681 700 Mountain Avenue, Room 2C-282 fax: (908)582-3340 Murray Hill, NJ 07974 web: http://www.cs.bell-labs.com/~jmc