On Tue, 2 Dec 2003, Hadley Wickham wrote: > Why not? A data frame is a convenient way of grouping related data > together. So is an object. Writing with(expr, a + b) is just shorthand > for writing expr$a + expr$b, so why shouldn't I be able to write > with(obj, a + b) for [EMAIL PROTECTED] + [EMAIL PROTECTED]
It is a bad idea because it has to break the information hiding that is an important point of objects. If you define a class "A" that either includes or inherits from another class "B" then you don't know what slots your object has (without looking at the internals of the implementation of class "B"). Suppose you define slots a and b in addition to whatever you have inherited. You don't know what with(obj, a+x) will do: is it [EMAIL PROTECTED] or [EMAIL PROTECTED]@x for some inherited slot x? And even worse, if someone extends your class and adds a slot x in the subclass, what should it do? Now, as it happens, the function slotNames() will give you all the slots, so it is possible to work out where x is, but this doesn't make it a good idea. Without rewriting the internal code for eval() it is also hard to do: it would require either a recursive search through the expression changing slot names to [EMAIL PROTECTED], or a function to convert objects into environments that could be fed to eval(). -thomas ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help