Right, thanks for the catch. Actually, field names "s", "se", "sel" would also produce the bug. Partial matching of argument names bites again. This should be fixed in r-devel and 2.14 patched, as of SVN rev. 57842.

Do try to follow the API in the documentation and use generator objects for reference classes. It's simpler than using S4 new() and makes it clear that the example is of a reference class.

John

On 12/7/11 7:36 AM, Janko Thyson wrote:
Dear list,

I think I stumbled across a little bug with respect to the standard
initialization routine for Reference Classes.

It seems that a field 'self' is treated as if it's name would be
'.self' (which we know is reserved for the self reference of the
instantiated object itself) and thus an error is thrown.
If the field value is assigned in an explicit call after the
instantiation via 'new()', everything works just fine:

setRefClass("ClassInfo",
        fields=list(
            self="character", super="character", sub="character"
        )
    )
    new("ClassInfo", self="B", super="A", sub="C")    # Error

    x <- new("ClassInfo", super="A", sub="C")
    x
    x$self <- "B" # Works
    x

Best regards,
Janko

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to