Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Differences between environments and lists #734

Merged
merged 1 commit into from
Jan 23, 2017
Merged

Conversation

ijlyttle
Copy link
Contributor

This set of proposed changes is admittedly pedantic - but I noticed that you made the point earlier that the objects live outside the environment. This is a very useful point.

I tried to find a way to rephrase the first two items such that they could not confuse this earlier point.

This set of proposed changes is admittedly pedantic - but I noticed that you made the point earlier that the objects live outside the environment. This is a very useful point.

I tried to find a way to rephrase the first two items such that they could not confuse this earlier point.
@hadley hadley merged commit bd2d844 into hadley:master Jan 23, 2017
@hadley
Copy link
Owner

hadley commented Jan 23, 2017

That's great - thanks! Advanced R is all about being pedantic 😁

MarceloRTonon added a commit to MarceloRTonon/adv-r that referenced this pull request Oct 22, 2020
Okay, I just read the issue hadley#734 and I understand that there is a delicate situation here:

- Saying that every object in an Environment must have an unique name is **conceptualy wrong**. 

- It is also not recommendable to leave as it is today. It takes some reading to undo the confusion that this makes.

To say that "Every name must be unique", make it seems that, in this matter, the difference between lists and environments is just that two elements of a list can have the same name, but not in an environment. Yes, this is truth, but is an incomplete truth.


As it is written today, it makes you think that the difference is that `l` can have 2 elements named "a", while `e` cannot.

``` r
l <- list("a" =1, "a" =2, "b" = 3)
  
e <- rlang::env("a" = 1, "a" = 2, "b" = 3)
  
l
#> $a
#> [1] 1
#> 
#> $a
#> [1] 2
#> 
#> $b
#> [1] 3
 
rlang::env_print(e)
#> <environment: 0000000013A104A8>
#> parent: <environment: global>
#> bindings:
#>  * a: <dbl>
#>  * b: <dbl>

```
<sup>Created on 2020-10-22 by the [reprex package](https://reprex.tidyverse.org) (v0.3.0)</sup>

This does not makes it simplier to the reader understand that an environment is the set of names that binds objects with names. It only makes it seem that an environment is list that does not allow repeated names (and with the other elements, that it does not order it). Therefore I suggest to change the present text adding a fifth difference (that it cannot have an element not binded to a name in an environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants