Alan Jeffrey, Mozilla Research
      
        Alan Jeffrey,
	Mozilla Research,
	LOLA 2016
      
    
      A few of the >1400 Rust contributors
    
    
    
    Systems programming language.
Hack without fear!
Safety guarantees based on two 1990s ideas:
Nothing can be included in Rust that isn't at least a decade old.
            — Graydon Hoare, Rust founder.
      Jean-Yves Girard, Linear logic, Theoretical Computer Science 50(1), 1987.
    
	Got water
	  and flowers
 
	Got water
	  and flowers
	  and a friend who will barter flowers for cigarettes
 
	Got water
	  and flowers
	  and a friend who will barter flowers for cigarettes
	  ...later...
          Got water
	  and cigarettes
 
	water
	  ⊗ flowers
	  ⊗ (flowers ⊸ cigarettes)
	  ⊢ 
          water
	  ⊗ cigarettes
water
	⊗ flowers
	⊗ (flowers ⊸ cigarettes)
	
 ⊢ 
        water
	⊗ cigarettes
water
	⊗ flowers
	⊗ (flowers ⊸ cigarettes)
	
 ⊢ 
        water
	⊗ cigarettes
models a friend who barters once and then vanishes
water
	⊗ flowers
	⊗ !(flowers ⊸ cigarettes)
	
 ⊢ 
        water
	⊗ cigarettes
	⊗ !(flowers ⊸ cigarettes)
      
models a friend who barters as much as you like
LL does not have weakening (discard) or contraction (copy):
A ⊬ A ⊬ A ⊗ A
but recovers them for banged formulae:
!A ⊢ !A ⊢ !A ⊗ !A
      Gavin Bierman, Valeria de Paiva, Martin Hyland (seated) and Nick Benton, 
	A Term Calculus for Intuitionistic Linear Logic, Proc. TLCA, 1993
    
	Curry-Howard (constructive logic):
	    propositions are types,
	    proofs are typed programs
	Gang of Four (constructive linear logic):
	    propositions are linear types,
	    proofs are linearly typed programs
    
    
    
    Mutating in-place is attractive:
Mutating in-place has problems:
Linear types make this simpler.
Model in-place mutation by consuming the old value
	and producing a new one: A ⊸ A
This is call-by-value-return.
    
      Problem 1: doesn't scale well with multiple arguments.
    
      Problem 2: doesn't cope with arguments that aren't mutated, so can be aliased.
    Solution: use call-by-reference rather than call-by-value-result.
Rust has two reference types:
References are borrowed: if v : A then &v : &A (ditto &mut).
Rather than (A ⊗ B) ⊸ (A ⊗ C),
	mutating functions have type (&mut A ⊗ B) ⊸ C.
    But why is this sound?
      Mads Tofte and Jean-Pierre Talpin, 
	Implementation of the typed call-by-value λ-calculus using a stack of regions, Proc. PoPL, 1994
    
      Problem: this program suffers from use-after-free.
    
      Problem: this program suffers from use-after-free.
    Rust reference types actually carry lifetimes:
Functions are lifetime-polymorphic.
Lifetime inference usually allows lifetimes to be omitted.
      Example after lifetime inference.
    Rust lifetimes are very similar to Tofte-Talpin regions:
There are some differences:
      Map of the >500 Servo contributors