Re: Nim hashtable mapping strings to any type

2018-09-30 Thread twetzel59
I also found myself needing to override `virtual` C++ methods, but eventually I gave up on the library (the MEGA API).

Re: Nim hashtable mapping strings to any type

2018-09-30 Thread drywolf
Thanks for clarifying. Up to now I have had to manually patch C++ vTables to be able to override some C++ class method with a nim-generated proc. What I keep wondering is if nim is going to add some kind of support for that ... i.e. implementing or overriding virtual C++ class methods. In my cas

Re: Nim hashtable mapping strings to any type

2018-09-29 Thread mratsim
That was something that was in the manual as coming soon for about eight months before being removed: [https://github.com/nim-lang/Nim/commit/c671356d51488c96b4749a4d109b00d924e1f739](https://github.com/nim-lang/Nim/commit/c671356d51488c96b4749a4d109b00d924e1f739) This should still be happening

Re: Nim hashtable mapping strings to any type

2018-09-28 Thread drywolf
@mratsim Since I have already written my own custom vTable mechanism with nim macros and some emitted C++ code (in order to interop i.e. inherit with C++ base classes) ... I'm wondering what you meant by saying: > In the future you will also be able to use concepts and VTables. Is there somethi

Re: Nim hashtable mapping strings to any type

2017-11-08 Thread random898989
Thanks everyone for the insight and the suggestions! Guess I'll design with this constraint in mind then. Just one little thing, I'm not sure how I can get "any" to work as recommended since I've tried it and it refused to work. Can someone share some code please?

Re: Nim hashtable mapping strings to any type

2017-11-08 Thread Udiknedormin
@cdome Plus it's not that handy when using with objects, as far as I know?

Re: Nim hashtable mapping strings to any type

2017-11-07 Thread cdome
> type Any is the closest to what you want. It is also unsafe to use.

Re: Nim hashtable mapping strings to any type

2017-11-07 Thread mratsim
It seems like you want dynamic typing in a statically typed language. The proper way for heterogeneous collection of objects currently is: * with ref objects inheriting from the same base class. * with object variants In the future you will also be able to use concepts and VTables.

Re: Nim hashtable mapping strings to any type

2017-11-07 Thread Udiknedormin
* ref \--- there is no such a thing. Reference always points at an entity of a specific type. * auto \--- it's not a type per se, it can just appear in several contexts a type may appear. * object \--- it's a kind of a type (as in: "this is an object type"), not type per se * any \--- we

Nim hashtable mapping strings to any type

2017-11-07 Thread random898989
How do I instantiate a hashtable in Nim that maps strings to objects of any type? None of these seem to work: import tables var t = newTable[string, any]() var t = newTable[string, ref]() var t = newTable[string, auto]() var t = newTable[string, object]() I