Featherweight Swift (Formal Core Language)

None needed; successful communication depends on all participants. It's as much my responsibility as yours.

I agree!

Sorry, I'm afraid I don't know how to read that notation. Can you point me to a guide?

Yes, memory (not necessarily raw memory, but something that allows two variables to be bound to the same mutable value) is required for reference semantics. But the useful properties of value semantics all stem from the fact that you can reason about the behavior of value semantic types without introducing the complexities associated with memory. It's similar to what happens when you create a purely functional programming language and run it on real hardware, which always has mutation: the formal description of the language becomes simpler, and reasoning about code becomes simpler. The difference is that with value semantics

  • there's a more direct lowering to efficient machine code that takes advantage of the hardware's mutation, and
  • the many computations that are most naturally expressed in terms of mutation can be expressed directly.

But this is still just math (to be fair, so are Alias Types).

Sorry, by “just math,” I meant that it doesn't require any programming-specific notions beyond those of traditional algebra, where a variable is actually just a name for one unchanging value. I didn't mean to suggest that Alias Types aren't mathematically well-founded; I'm sure that they are.

There also has been some interesting approaches to do this "syntactically"; see [1] and subsequent work from Elena Zucca.

I'll take a look.

Now the question is: what do I want from this?

Did you ever answer that question? :slight_smile:

Whoa, how did you make those checkboxes? They don't show up in the quoted markdown.

Nit: you checked the first bullet, but I think to do that, you probably need to remove the word “independent,” which I take to effectively imply the 2nd-to-last bullet, which you didn't check (my list contains some intentional redundancy).

The two last points require a little more attention, because they are predicated upon a notion of reference.

Hmm, I'm not sure I buy that. They certainly don't use the word “reference” anywhere. They are predicated on the ability to alter the value associated with a variable. While that overlaps with the capabilities provided by what we think of as references, I claim it's significantly more restrictive.

This comes back to what I meant about the requirement to model memory as some sort of "store", so that two names can refer to the same thing.

Sorry, you lost me. I don't understand how you conclude there's a need to discuss names “referring” to anything from the language in those two bullets.

I like @Lantua's definition of so-called points of access (see Avoiding unbreakable reference cycle with value types and closures?) to describe this concept.

That seems like a useful way to describe a world with both value and reference semantics.

Again, I'll need some help with that notation.

That all sounds very interesting, but I'm afraid it doesn't make sense to me yet; I look forward to the moment where my understanding catches up with what you wrote :wink:

By the way, I'm open to move this discussion to a phone call, even if it means summarizing the exchange in text here afterwards.

Thanks for the offer. For the time being, I'd like to keep it here, though. The written form gives me enough time to consider everything you say, follow references, etc. without worrying about being frustratingly slow.

1 Like