You're reading the public-facing archive of the Category Theory Zulip server.
To join the server you need an invite. Anybody can get an invite by contacting Matteo Capucci at name dot surname at gmail dot com.
For all things related to this archive refer to the same person.
I've programmed in C++ a fair amount. What's aliasing? @sarahzrf
That would be references, I guess (and potentially also pointers)
There was some discussion on it in another stream since it has to do with Sarah's talk. There she said it had to do with pointers, and I guess something about having two distinct pointers point to the same thing.
Yeah, basically it refers to when two pointers point to the same thing or overlapping things, particularly when you didn't expect them to.
What's the deal with these? What sorts of issues make people say "oh what about aliasing?"
(the underlying language-independent concept can also be called names, ie. having multiple names for the same thing)
Aliasing + destructive updates = headache. Somebody can do something to , and suddenly has changed. It means you can't reason lexically
For example if you want to optimize a for loop, you might want to know that updates you make in the body of the for loop don't affect the value of the upper bound of the loop.
IIRC, copying an array is a classic thing that can be hit by aliasing. If source and target arrays overlap, the naïve algorithm will at some point start copying the start of the source array again, into the end of the target array (because it starts reading from the start of the target array, which has written over values from the source array).
Or imagine you are implementing a function that takes pointers to three matrices , , and updates according to the rule .
The obvious implementation won't work as claimed if the reference is the same as either or (but it's fine if and are the same reference). A variant of James's example.
Great, this is all making sense.
I had the sense that it should be a thing I encountered but just never saw a name put to it, and that's exactly what it was!
the standard issue with aliasing is that if the compiler cannot prove that pointers point to different things, it might have to reload a value from memory even when not necessary, because it cannot be sure that it hasn't been written by previous instructions
so C for example has a keyword (restrict
IIRC) to instruct the compiler that it is allowed to assume that two pointers point to non-overlapping areas, so that certain optimisations can be applied
reid's example ties in great with the kind of thing i would want to illustrate, actually
the kind of place you use separation logic in practice is generally for writing down specifications of the behavior of programs, such as saying "this program really does add matrices"
but of course, if you wrote the obvious implementation, that specification just isn't true—what if the matrices you pass in alias?
except that in separation logic, you can use "separating conjunction" instead of ordinary conjunction when necessary, and when you do so, you implicitly rule out such cases in your premise
so that the case you naïvely had in mind now really is what you're saying with your specification
the "separation" is as in "separation of the resources underlying the matrices from one another"