Learning Nim: Object Variants

preview_player
Показать описание
This is part 4 of an ongoing series of my efforts to learn the programming language Nim. I give you a quick overview on how to use object variants.

Contact:

#nim
Рекомендации по теме
Комментарии
Автор

nim macro are just amazing, thx for video.

СергейБакин-фр
Автор

Hi David!
Thank you for such compact wonderful lessons on using Nim, how nice it is to watch them! Nim is difficult for me. But I'm not giving up. Please tell me which plugins/packages for Nim do you use in Neovim? It would be wonderful if there was a video on "Nim development and debugging in Neovim" .
(Maybe like the next video in the playlist "Vim as IDE")

СергейБакин-фр
Автор

Nice tutorial. Thank you. After learning how to handle circular module dependencies in Nim I want to do a project in Nim.

kcvinu
Автор

Hopefully you can add more content to this series, specially now that Nim 2 is coming.

eduardabramovich
Автор

For my curiosity: Pascal (as defined by N. Wirth) had CASE variants to save memory in the early days of computing, where the memory size was 48 to 64K rather than 8-16G in the average today. How does nim handle those variants with respect to memory? Is memory allocated only for those parts that are active? Can shape.kind be set to a different value after the initial creation?

oaw_manofnorse
Автор

How does nim handle case: structures? I know in most other languages they tend to be quite slow and unreliable. Is nim different when it comes to switches?

moistgiraffe
Автор

Hey, great video on an important topic!
Why not use `^` if you import the whole `math` anyway?
Also, you don't need a conditional for an equality operator, as you can use `case` as an expression.

```
func `==` (shape1, shape2: Shape): bool =
shape1.kind == shape2.kind and shape1.color == shape2.color and
(case shape1.kind:
of Circle: shape1.radius == shape2.radius
of Square: shape1.length == shape2.length)
```

PS: I see you decided to leave the background music on... 🚔

ZoomRmc