* Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset [not found] ` <20201031133158.04C1220A1C@vcs0.savannah.gnu.org> @ 2020-10-31 15:06 ` Stefan Monnier 2020-11-01 9:39 ` Mattias Engdegård 0 siblings, 1 reply; 6+ messages in thread From: Stefan Monnier @ 2020-10-31 15:06 UTC (permalink / raw) To: emacs-devel; +Cc: Mattias Engdegård > * lisp/emacs-lisp/byte-opt.el (side-effect-free-fns): Remove 'assoc'. Oh, indeed: nasty. `assoc` *was* side-effect-free until it grew its new `testfn` argument. Stefan ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset 2020-10-31 15:06 ` master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset Stefan Monnier @ 2020-11-01 9:39 ` Mattias Engdegård 2020-11-01 9:47 ` Andrea Corallo via Emacs development discussions. 0 siblings, 1 reply; 6+ messages in thread From: Mattias Engdegård @ 2020-11-01 9:39 UTC (permalink / raw) To: Stefan Monnier; +Cc: emacs-devel 31 okt. 2020 kl. 16.06 skrev Stefan Monnier <monnier@iro.umontreal.ca>: > Oh, indeed: nasty. `assoc` *was* side-effect-free until it grew its new > `testfn` argument. We do have a number of functions that are pure or side-effect-free unless given certain arguments. I suppose we could design a system that encompasses these cases. Certainly wouldn't mind algebraic effect types! ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset 2020-11-01 9:39 ` Mattias Engdegård @ 2020-11-01 9:47 ` Andrea Corallo via Emacs development discussions. 2020-11-01 12:56 ` Mattias Engdegård 0 siblings, 1 reply; 6+ messages in thread From: Andrea Corallo via Emacs development discussions. @ 2020-11-01 9:47 UTC (permalink / raw) To: Mattias Engdegård; +Cc: Stefan Monnier, emacs-devel Mattias Engdegård <mattiase@acm.org> writes: > 31 okt. 2020 kl. 16.06 skrev Stefan Monnier <monnier@iro.umontreal.ca>: > >> Oh, indeed: nasty. `assoc` *was* side-effect-free until it grew its new >> `testfn` argument. > > We do have a number of functions that are pure or side-effect-free > unless given certain arguments. I suppose we could design a system > that encompasses these cases. Certainly wouldn't mind algebraic effect > types! Hi Mattias, just ot mention, would be nice if we design this to be accessible so we can use it in the native compiler as well maintaining it just in one place. Andrea ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset 2020-11-01 9:47 ` Andrea Corallo via Emacs development discussions. @ 2020-11-01 12:56 ` Mattias Engdegård 2020-11-01 14:07 ` Stefan Monnier 0 siblings, 1 reply; 6+ messages in thread From: Mattias Engdegård @ 2020-11-01 12:56 UTC (permalink / raw) To: Andrea Corallo; +Cc: Stefan Monnier, emacs-devel 1 nov. 2020 kl. 10.47 skrev Andrea Corallo via Emacs development discussions. <emacs-devel@gnu.org>: > just ot mention, would be nice if we design this to be accessible so we > can use it in the native compiler as well maintaining it just in one > place. It wasn't really meant seriously, but a simple system may look like EFFECT ::= nil ; no effect (subset of all effects) | * ; any effect (superset of all effects) | signal ; signal any condition (error etc) | read-env ; read from the global environment | N ; effect of function passed as argument N, N≥1 | (union EFFECT...) ; union of effects Then today's declarations correspond to the effects: pure ~ signal side-effect-free ~ (union signal read-env) error-free ~ read-env and the effects of 'assoc' would be (union signal 3). More fine-grained effects could be added, such as throws, mutation of arguments, reading data referenced by arguments, etc. It all depends on what is useful for the compiler(s) and related tools. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset 2020-11-01 12:56 ` Mattias Engdegård @ 2020-11-01 14:07 ` Stefan Monnier 2020-11-02 5:40 ` Richard Stallman 0 siblings, 1 reply; 6+ messages in thread From: Stefan Monnier @ 2020-11-01 14:07 UTC (permalink / raw) To: Mattias Engdegård; +Cc: emacs-devel, Andrea Corallo > It wasn't really meant seriously, but a simple system may look like > > EFFECT ::= > nil ; no effect (subset of all effects) > | * ; any effect (superset of all effects) > | signal ; signal any condition (error etc) > | read-env ; read from the global environment > | N ; effect of function passed as argument N, N≥1 > | (union EFFECT...) ; union of effects Side note: this sounds good (I've been thinking along very similar lines recently to try and improve the docs of `pure` and `side-effect-free`), but note that nil has to me "any effect" since most functions will come with no annotation at all (which most is most naturally mapped to nil). Also, there are a few functions which we're willing to constant-fold even though they can have "minor" side-effects (the cases I can think of seem to be mostly about clobbering the match-data, so maybe all it means is that we need is an additional `clobbers-match-data`, which means that the contents of the match-data can't be relied upon after the call). > More fine-grained effects could be added, such as throws, mutation of > arguments, reading data referenced by arguments, etc. If we ever want to be able to detect match-data errors via static analysis, we'd need to know which functions set the match data, which functions are guaranteed not to affect the match-data, and which functions read the match data (then we can warn any time you read the match data even though you called a function not known to preserve the match-data since the last call to a match-data-setting function). Now admittedly, "preserve the match-data" is not really an effect ;-) > It all depends on what is useful for the compiler(s) and related tools. Indeed, we should keep things as simple as possible. For me the main benefit is that it seems easier to explain those effects than to explain what it means to be "pure" or "side-effect-free", probably because both of those terms already exist in computer-English but with not 100% precise meanings and that our use doesn't match 100% either. Stefan ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset 2020-11-01 14:07 ` Stefan Monnier @ 2020-11-02 5:40 ` Richard Stallman 0 siblings, 0 replies; 6+ messages in thread From: Richard Stallman @ 2020-11-02 5:40 UTC (permalink / raw) To: Stefan Monnier; +Cc: mattiase, akrl, emacs-devel [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] Perhaps it was a mistake to add the TESTFN argument to assoc. Maybe we should eliminate it and create another function which accepts additional arguments. -- Dr Richard Stallman Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org) ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-02 5:40 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <20201031133156.28415.87445@vcs0.savannah.gnu.org> [not found] ` <20201031133158.04C1220A1C@vcs0.savannah.gnu.org> 2020-10-31 15:06 ` master 0cbcc62: 'assoc' is not side-effect-free; constprop its pure subset Stefan Monnier 2020-11-01 9:39 ` Mattias Engdegård 2020-11-01 9:47 ` Andrea Corallo via Emacs development discussions. 2020-11-01 12:56 ` Mattias Engdegård 2020-11-01 14:07 ` Stefan Monnier 2020-11-02 5:40 ` Richard Stallman
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).