Open mfelsche opened 7 years ago
Please also include Array examples
I would have started to write up something but i don't feel confident enough with pony yet.
I've spent half an hour to implement basic Map container member within a class and ...failed :-/ The type constraints are not clear. Could someone add into tutorial or into example section of repository a clear example on how could one work with Map, please?
We agreed on adding a section about collection on the precondition that the actual collection docstrings and package documentation will have some serious overhaul and this section will be more of a starting point for a guided tour of the standard library with pointing people into the right direction and refers to the stdlib docs.
Ha, I also had a hard time figuring out how to create a HashMap
. In case other people end up here as I did:
let m = HashMap[U64, String, HashIs[U64]].create()
will do the trick!
As far as I understand (started to read the pony tutorial 2h ago):
primitive
is a type which can only contain functions (useful to implement stateless traits and interfaces)HashIs[A]
[0] is a primitive
which implements both hashable interfaces: Hashable
and Hashable64
.(digestof x)
on anything (even tags).Please let me know if my understanding is wrong!
Personal opinion significantly in the future of when this issue was last discussed during sync, to add a chapter like this I would want to move Object Capabilities after Generics then put this chapter after Generics.
In brief, currently the order is:
Changing to:
I'm not in favor of "chapter on collections". I'm in favor of adding at the end of the tutorial a "tour through the standard library" that highlights the most commonly used things that we want people to be aware of like net
, collections
, and what not.
@SeanTAllen A tour of the standard library sounds fair. I see that tour being placed after "Gotchas" and before "Where Next?" Any objection to that?
Sounds good to me @rhagenson.
As a newcomer to pony (coming from java, scala, python, erlang) i would really really love to see a section about collections in the tutorial as this a pretty important building block of day to day programming (next to primitives, classes, actors ...).
Useful information would be:
Map.upsert
andMap.insert_if_absent
Most of this is not directly uniquely related to pony but knowledge of how to powerful the language is in terms of solving day to day problems would really help getting a feeling about the language and help people get into it.