3 ms·
Last I worked with Nim, the most frustrating aspects of it were how it implemented tuples and multi-threading. Tuples are really more akin to records, which na
by massung 5y ago
Last I worked with Nim, the most frustrating aspects of it were how it implemented tuples and multi-threading.
Tuples are really more akin to records, which name their fields. Because of that, I found many things quite difficult to do since I couldn't just return and work with a generic tuple type; read: (int, string) doesn't equal (int, string) because one is forced to name the elements and magically know the names of elements as well from returned tuples.
And multi-threading was just a mishmash of ideas, none seemed "blessed" or really 1.0 worthy (as of 1.0).
Those two issues aside, I really liked Nim when I tried it. Maybe the issues above aren't issues any more and I should take another look?
- matthiaswh 5y agoI believe the only time you have to name a tuple is when you define a tuple type. You can otherwise easily work with "anonymous" tuple fields. https://play.nim-lang.org/#ix=2lK1 https://play.nim-lang.org/#ix=2lK1 Tuples with anonymous fields are equivalent to those with named fields as long as the types and values match. Two tuples with differently named fields will not be equivalent even if their values are. > magically know the names of elements as well from returned tuples. This is not magic, is it? No more so than knowing the return type.
- uryga 5y ago> https://play.nim-lang.org/#ix=2lK1 https://play.nim-lang.org/#ix=2lK1 which part of the link shows using tuples? i can't really see anything tuple-like really
- pietroppeter 5y agoYou can return a generic tuple and you do not need to know the names when using a returned tuple: https://play.nim-lang.org/#ix=3qTu https://play.nim-lang.org/#ix=3qTu
- irq-1 5y agoAnonymous tuples: echo (3,5,7) let (x, y) = ( "X", "Y" ) echo x, y (3, 5, 7) XY
- planetis 5y ago> Maybe the issues above aren't issues any more and I should take another look? Yes and no. With destructors we are finally able to use multihreading without resorting to raw pointers. However its very wip. I am making a lib if you like to try it out https://github.com/planetis-m/sync https://github.com/planetis-m/sync and give some feedback.
- kaushalmodi 5y agoIf you begin using tuples with named fields, they will technically be of a different type than anon tuples. To keep it simple, just use anon tuples consistently everywhere. I have some notes on tuples in Nim: https://scripter.co/notes/nim/#tuples https://scripter.co/notes/nim/#tuples