> On 10 Feb 2024, at 11:10, Al <frm...@mailgw.com> wrote: > > On 2024-02-10 11:53, Pietro Cerutti wrote: > >> I don't see why vector-ref would be any less pure than, say, a let binding. >> Or do you mean vector-set! ? >> > vector-ref, applied to a global, could return different values even when > called with the same arguments. Between calls, some other code could modify > the contents of the vector. So according to referential transparency, > vector-ref could not be pure. Likewise a function that calls vector-ref could > not be pure. > > Further, according to referential transparency no procedure that *reads* a > global (not just vectors -- even imediate values like numbers, booleans) can > be pure. It might return different values if impure code modifies the global > between calls to the procedure in question.
This is not how I reason about referential transparency. It is a property of functions applied to values, not variables. The fact that you can define x to different values or even rebind it in the scope of a let binding doesn't make (lambda (x) (+ x 1)) less referentially transparent. If you change the value of a slot of a vector, then the vector has a different value than before, even if the same name binds to the value. -- Pietro Cerutti I've pledged to give 10% of income to effective charities and invite you to join me. https://givingwhatwecan.org Sent from a small device - please excuse brevity and typos.