Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-28 Thread Gabriel Becker
Abs, Inline. On Thu, Mar 28, 2019 at 8:10 PM Abs Spurdle wrote: > I know I said that I had no further comments on object oriented semantics. > However, I found a contradiction in the R documentation. > > > Gabriel Becker wrote: > > So, there are implicit classes, but *only when the data object

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-28 Thread Abs Spurdle
I know I said that I had no further comments on object oriented semantics. However, I found a contradiction in the R documentation. Gabriel Becker wrote: > So, there are implicit classes, but *only when the data object is NOT an "R object" In the R Language Definition: > The R specific function

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-28 Thread Hadley Wickham
On Wed, Mar 27, 2019 at 6:27 PM Abs Spurdle wrote: > > > the prison made by ancient design choices > > That prison of ancient design choices isn't so bad. > > I have no further comments on object oriented semantics. > However, I'm planning to follow the following design pattern. > > If I set the c

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-28 Thread Martin Maechler
> Abs Spurdle > on Thu, 28 Mar 2019 12:26:36 +1300 writes: >> the prison made by ancient design choices > That prison of ancient design choices isn't so bad. > I have no further comments on object oriented semantics. > However, I'm planning to follow the following des

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-27 Thread Abs Spurdle
> the prison made by ancient design choices That prison of ancient design choices isn't so bad. I have no further comments on object oriented semantics. However, I'm planning to follow the following design pattern. If I set the class of an object, I will append the new class to the existing clas

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-27 Thread Hadley Wickham
I would recommend reading https://adv-r.hadley.nz/base-types.html and https://adv-r.hadley.nz/s3.html. Understanding the distinction between base types and S3 classes is very important to make this sort of question precise, and in my experience, you'll find R easier to understand if you carefully d

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread Gabriel Becker
Abs et al, Ok, so I have just gone and re-read the docs again. My language was a more absolute than it should have been; *however*, I was still correct for the cases under discussion. >From ?UseMethod (emphasis mine) An R object is a data object which has a ‘class’ attribute (and this can

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread Abs Spurdle
> you had seemed to be presenting it as something new in 3.5.3. I would be surprised if the behavior doesn't go all the way back to whenever head.function was added. My bad. I'm just surprised I've never noticed these problems before. > S3 classes have no formal definitions at all > I'm not sure

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread William Dunlap via R-devel
I think this goes back to SV4 (c. late 1990's). The is. functions are much older (c. mid 1970's) , from before any class system was in S. is() and inherits() were introduced with the S4 class system and were meant to escape from the prison made by ancient design choices. Bill Dunlap TIBCO Softwa

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread Gabriel Becker
Hi Abs, Lets try to remain civil even when disagreeing about major design philosophies, ok? On Tue, Mar 26, 2019 at 2:08 PM Abs Spurdle wrote: > If I can merge this thread with the one I started yesterday... > > > "If the object does not have a class attribute, it has an implicit > class..." >

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread Abs Spurdle
If I can merge this thread with the one I started yesterday... > "If the object does not have a class attribute, it has an implicit class..." > which I take to mean that if an object does have a class attribute it does not also have an implicit class. > I think this is reasonable behavior. Conside

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread Rui Barradas
Hello, Here is another example. df1 <- data.frame(a = 1:3, b = 4:6) inherits(df1, "data.frame") #[1] TRUE class(df1) #[1] "data.frame" inherits(df1, "list") #[1] FALSE This is documented behavior, the help page ?inherits says The function class prints the vector of names of classes an objec

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-26 Thread Berry, Charles
In the case of inherits (at least) this seems intended. The help page says: "If the object does not have a class attribute, it has an implicit class..." which I take to mean that if an object does have a class attribute it does not also have an implicit class. The behavior you noted below will

Re: [Rd] Discrepancy between is.list() and is(x, "list")

2019-03-25 Thread Abs Spurdle
> I have noticed a discrepancy between is.list() and is(x, “list”) There's a similar problem with inherits(). On R 3.5.3: > f = function () 1 > class (f) = "f" > is.function (f) [1] TRUE > inherits (f, "function") [1] FALSE I didn't check what happens with: > class (f) = c ("f", "function") H

[Rd] Discrepancy between is.list() and is(x, "list")

2019-03-11 Thread Shian Su
Hi R-devel, I have noticed a discrepancy between is.list() and is(x, “list”), which I previously believed to be synonymous. On R version 3.5.2 (2018-12-20): data(iris) is.list(iris)# TRUE is(iris, “list”) # FALSE Is this discrepancy intentional? Kind regards, Shian Su