3 ms·
The lifetime syntax was taken from OCaml but it has somewhat different semarics than OCaml. I honestly get a bit tripped up when I look at OCaml code (a languag
by JuniperMesos 11mo ago
The lifetime syntax was taken from OCaml but it has somewhat different semarics than OCaml. I honestly get a bit tripped up when I look at OCaml code (a language I'm a beginner at), and see ordinary parameterized types using syntax that suggests to me, from a Rust background, "woah, complex lifetime situation ahead!"
I know that Graydon Hoare is a fan of OCaml and that it was a core inspiration for Rust, and I sometimes wonder if he gets tripped up too by having to switch between Rust-inspired and OCaml-inspired interpretations of the same characters.
- steveklabnik 11mo agoIt's similar but different: both are type variables, but it's true that it's used for the "other" type variables in Rust. For what it's worth, I am not even sure that Graydon was the one who introduced lifetime syntax. He was a fan of terseness, though: Rust's keywords used to be all five characters or shorter. Niko and pcwalton were the ones working on regions, Niko talks a little bit about the motivation for syntax here: https://smallcultfollowing.com/babysteps/blog/2012/03/28/avoiding-region-explosion-in-rust/ https://smallcultfollowing.com/babysteps/blog/2012/03/28/avo... Later posts include /& as syntax: https://smallcultfollowing.com/babysteps/blog/2012/04/25/references/ https://smallcultfollowing.com/babysteps/blog/2012/04/25/ref... Eventually, another syntax: https://smallcultfollowing.com/babysteps/blog/2012/07/10/borrowed-pointer-tutorial/ https://smallcultfollowing.com/babysteps/blog/2012/07/10/bor... which turns into a &x/ syntax: https://smallcultfollowing.com/babysteps/blog/2012/07/17/borrowed-pointer-tutorial/ https://smallcultfollowing.com/babysteps/blog/2012/07/17/bor... Which turns into this one, talking about variants of possible syntax: https://smallcultfollowing.com/babysteps/blog/2012/12/30/lifetime-notation/ https://smallcultfollowing.com/babysteps/blog/2012/12/30/lif... At some point, we get the current syntax: https://smallcultfollowing.com/babysteps/blog/2013/04/04/nested-lifetimes/ https://smallcultfollowing.com/babysteps/blog/2013/04/04/nes... So, it happened somewhere in here...