-
-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More real world example in destructive read documentation #281
Comments
Something like a destructive read to swap an iso would be my idea (like in |
I think we may want to avoid getting into capabilities stuff like Maybe just making it an example with a let map = Map[String, U64]
map("key1") = 100
map("key2") = 200
map("key1") = map("key2") = map("key1") |
There is currently an example of destructive read using an pony-tutorial/content/reference-capabilities/consume-and-destructive-read.md Lines 40 to 49 in 7e88041
The Twitter thread appears like it was a barrier of first look at syntax, not lack of presence in the tutorial. The use in types/classes: pony-tutorial/content/types/classes.md Lines 162 to 172 in 7e88041
May be a bit much too soon. Do we want a "real world" example using Map (which then might confuse with the square brackets of generics), or for me to modify in-place to present it as a shorthand of syntax for swapping variables? |
I'm thinking that rather than the tutorial, perhaps we want to cover the usage of destructive read in 1 or more pony patterns. As it is, a more "advanced" topic. At the least using on iso fields is definitely an advanced topic worthy of a pony pattern. |
I agree on destructive reads as a pattern entry. Destructive reads are an essential part of using Pony to its fullest (IMO), but their use amounts to a pattern as it is not something one must use, but should be aware of when reading Pony code. |
A "real world example" using something like Map might fit in a Collections chapter as requested in #190 |
I think that the destructive read pattern comes up so infrequently in practice that the existing example mentioned by @rhagenson is sufficient for explaining when it may be needed. |
Added the "good first issue" label because I want someone's perspective on where a review/reminder of destructive read may be useful. The concept is not not covered, but a second mention that is not distracting would be helpful for anyone reading the Tutorial through the first time. |
In the introductory documentation for assignment and destructive reads (pony-tutorial/types/classes.md), a simple example is given of how you can swap a value in Pony with:
I mentioned this was a bit opaque on twitter, and exchanged some comments with @ponylang account, leading to this issue being filed.
It would perhaps be better to given a more concrete real world example here, or maybe link to the section that documents the "awesome things with a capabilities-secure type system".
The text was updated successfully, but these errors were encountered: