Re: Containers of generic types

2017-09-15 Thread Jehan
You can do pretty traditional OOP in Nim if you want to (except for proper abstract methods). Here's an example: # main.nim # Free Public License 1.0.0 # # Permission to use, copy, modify, and/or distribute this software for # any purpose with or without fee is

Re: Containers of generic types

2017-09-15 Thread gokr
In other words, the "problem" is that in order for you to be able to stuff a bunch of items into a "bag", shake the bag, and then pull one out of it - and **still knowing the type of what you pulled out** \- requires storing type information together with each item. Nim, as many statically

Re: Containers of generic types

2017-09-14 Thread Tiberium
cdome: but one problem - vtrefs are not implemented yet

Re: Containers of generic types

2017-09-14 Thread cdome
vtref of concepts will do that. You can define a union type if you want to. There are other options, I don't see a problem here

Re: Containers of generic types

2017-09-14 Thread dawkot
Yes, I'm talking about storing different type values in one container, but in a safer way than by casting/storing raw pointers to values. In some other languages you can use interfaces for that, but if that's not possible in nim that would mean this feature is based on a VM?

Re: Containers of generic types

2017-09-14 Thread LeuGim
Probably you're asking about what here is discussed: [https://forum.nim-lang.org/t/3150](https://forum.nim-lang.org/t/3150); that is, on storing different (concrete) type values in one container. You have to choose between casts, object variants, refs to objects + dynamic dispatch (methods),

Re: Containers of generic types

2017-09-14 Thread Araq
No idea what you're talking about.

Containers of generic types

2017-09-14 Thread dawkot
Right now it's impossible to use containers based on generic types. Is it going to change, or is there some alternative?