On Wed, 20 Jul 2005, John Chambers wrote: > Paul Roebuck wrote: > > > Is it possible for S4 to (continue) dispatch to a class > > created during dispatching? The code below doesn't work; > > is this not possible or have I ommitted something? > > "doesn't work"? This is not helpful. Please show what you got and what > you expected. The result below is what I would expect (& get) from your > code. > > R> onthefly("testing") > generic onthefly > onthefly (character) > generic onthefly > onthefly (mydata) > List of 1 > $ name: chr "mydata" > - attr(*, "class")= chr "mydata" > > Since you used an undefined class "mydata" you can't expect very much > else to work with these objects. You did not in fact "create" the > class, you just assigned a class attribute to an object corresponding to > an undefined class. There is a warning message to that effect from the > second setMethod() call.
In retrospect, that should have been expressed as "doesn't work as I expected". I was using 'options(warn=2)' and didn't notice the warning conversion. I expected evaluation of the class existence would occur when callGeneric() was invoked, not during setMethod(). Also surprised at the return to generic prior to the final dispatch (instead of going straight there) along that same line of thought. While it's true that all I did was add a class attribute to the object, I thought that was all that was required for a trivial S3 class to be "defined". In my case, it is solely for internal usage as an intermediate data object that allows R to handle its memory management. Not sure how to define an S4 class representation for an external pointer. Thanks for your patience and help. ---------------------------------------------------------- SIGSIG -- signature too long (core dumped) ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel