From jon.clayden at gmail.com  Fri Aug  5 22:10:07 2011
From: jon.clayden at gmail.com (Jon Clayden)
Date: Fri, 5 Aug 2011 21:10:07 +0100
Subject: [Rd] initFields() method no longer coerces arguments in R-devel
In-Reply-To: <4E3C26D8.3030300@r-project.org>
References: <CAM9CR=2fg_5io9xGZnW86JB-51BOTqxH_Ui=gPh5odciPa7eGA@mail.gmail.com>
	<050B398D-DF57-49E5-8DB3-9DCB3D33E984@r-project.org>
	<4E3C26D8.3030300@r-project.org>
Message-ID: <CAM9CR=1F4ji7b13UyrPE--0nQ0eE13BAi6BnC5FM7zZ-9wxayw@mail.gmail.com>

OK, apologies - on both fronts I obviously searched on the wrong
terms. Sorry to waste your time.

Jon


On 5 August 2011 18:22, John Chambers <jmc at r-project.org> wrote:
> There is also an item in the NEWS file:
>
> ? ?Field assignments in reference classes are now consistent with slots in
> S4 classes: the assigned value must come from the declared class (if any)
> for the field or from a subclass.
>
> On 8/5/11 7:24 AM, Simon Urbanek wrote:
>>
>> It's worth actually reading the list you post to ...
>>
>> http://r.789695.n4.nabble.com/Reference-classes-assignments-to-fields-td3708168.html
>>
>>
>> On Aug 5, 2011, at 6:41 AM, Jon Clayden wrote:
>>
>>> Dear all,
>>>
>>> I've just had a package update bounced from CRAN because of a recent
>>> change in R-devel which seems to affect the behaviour of the
>>> initFields() reference class method. (The change must be very recent
>>> because I tested the package on a week-old build of R-devel.) It seems
>>> that the method no longer coerces its arguments to the expected type
>>> of each field. For a simple example:
>>>
>>>> Foo<- setRefClass("Foo", fields=list(number="integer"),
>>>> methods=list(initialize=function (number = NULL) initFields(number=number)))
>>>> Foo$new()
>>>
>>> Error in function (value) ?:
>>> ?invalid replacement for field ?number?, should be from class
>>> ?integer? or a subclass (was class ?NULL?)
>>>
>>> (This used to work, with "number" being set to "integer(0)"). In fact
>>> it is now extremely strict, not even allowing a double literal which
>>> is equal to an integer:
>>>
>>>> Foo$new(number=1)
>>>
>>> Error in function (value) ?:
>>> ?invalid replacement for field ?number?, should be from class
>>> ?integer? or a subclass (was class ?numeric?)
>>>
>>> I don't see anything about this in the NEWS, so I was wondering if I
>>> could get clarification on whether this is now the intended behaviour,
>>> before I further modify the package. I must say that this will be a
>>> bit of a pain to "correct"...
>>>
>>> All the best,
>>> Jon
>>>
>>> ______________________________________________
>>> R-devel at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>>
>>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] initFields() method no longer coerces arguments in R-devel
Jon Clayden