ponylang / pony-tutorial

:horse: Tutorial for the Pony programming language
http://tutorial.ponylang.io
BSD 2-Clause "Simplified" License
310 stars 111 forks source link

consume with capability should be documented #470

Closed ergl closed 3 years ago

ergl commented 3 years ago

Currently we cover consume on the Consume and Destructive Read section, but the text only uses it in the context of assigning the result to an iso variable:

fun test(a: Wombat iso) =>
  var b: Wombat iso = consume a // Allowed!

We should mention that consume accepts an optional capability, like consume val or consume ref, although you can omit the capability and annotate the variable you're assigning:

let b: Wombat val = consume b 
let b = consume val b // Same as above

This is similar to what can be done with recover, so I'm unsure if this should go in the "Consume and Destructive Read" section or in the "Recovering Capabilities" section.