Timeline for Is there a way to spread a list like in Typescript or Golang?
Current License: CC BY-SA 4.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 17, 2020 at 9:24 | history | edited | user19761 | CC BY-SA 4.0 |
added 69 characters in body; added 2 characters in body
|
Jul 17, 2020 at 9:16 | history | edited | user19761 | CC BY-SA 4.0 |
deleted 607 characters in body
|
Jul 16, 2020 at 18:54 | history | edited | user19761 | CC BY-SA 4.0 |
added 73 characters in body
|
Jul 16, 2020 at 18:45 | history | edited | user19761 | CC BY-SA 4.0 |
added 130 characters in body; added 89 characters in body; added 315 characters in body
|
Jul 16, 2020 at 18:41 | comment | added | user19761 | @NickD: See also, section "2.9 Mutability" and "10.4 Backquote" and "10.2.1 Self-Evaluating Forms" in the Elisp manual (version 27). | |
Jul 16, 2020 at 18:34 | comment | added | user19761 | @NickD: That's not quite right, but I think it ties in with the idea (debbugs.gnu.org/cgi/bugreport.cgi?bug=40671#414). I think this has to do with the functional paradigm, in particular to avoid undesirable side effects. The compiler or interpreter can replace some objects with references to a single object. Except that if you modify the object, you change all the other values during evaluation: a function returns the wrong value. | |
Jul 16, 2020 at 17:10 | comment | added | NickD | OK - now I understand what you are talking about: because list structure may be shared, and the shared part of list structure may include a "constant" list , which, through hash consing (or perhaps another mechanism) happens to be used by an entirely different list in some other part of emacs, then changing the "constant" list in one place will affect the other. Is that the concern? | |
Jul 16, 2020 at 16:58 | history | edited | user19761 | CC BY-SA 4.0 |
added 106 characters in body
|
Jul 16, 2020 at 16:55 | comment | added | user19761 | @NickD: The issue is that Elisp may "merge" literal objects so IMO it is better to not store literal objects in "variables". | |
Jul 16, 2020 at 16:45 | comment | added | user19761 |
@NickD: no, I'm just saying it's better to assign a new list than a literal list. For instance, it is better to do this (setq lst (list 'a 'b)) rather than (setq lst '(a b)) .
|
|
Jul 16, 2020 at 16:01 | comment | added | NickD |
So what? Are you proposing outlawing setcar and its ilk?
|
|
Jul 16, 2020 at 15:30 | comment | added | user19761 |
@NickD: These objects are not explicitly modified, but neither should they be implicitly modifiable. You can modify the constant list through the variable: (setcar another-variable 0 'a) .
|
|
Jul 16, 2020 at 14:37 | comment | added | NickD |
Not sure exactly what you are objecting to, since in my example I do not modify existing list structure at all. I did not read all of the bug you referred to, but AFAICT all of the examples that are discussed involve modifying a "constant" list, which (I think) I'm not doing. How is the fact that append does not copy its final argument make any difference to the example in my answer?
|
|
Jul 16, 2020 at 13:47 | history | edited | user19761 | CC BY-SA 4.0 |
added 92 characters in body; added 5 characters in body; added 7 characters in body; added 5 characters in body
|
Jul 16, 2020 at 13:32 | history | answered | user19761 | CC BY-SA 4.0 |