Re: Bug with generic methods?

2017-09-04 Thread LeuGim
> Please note the biggest problem of inheritance-based interfaces: you cannot > add one to a type already in existence when you define the interface Certainly you cannot; that is the point - not interfaces state, what types satisfy (implement) them, but the other way round, types state, what

Re: Bug with generic methods?

2017-09-04 Thread LeuGim
> two interfaces or concepts requiring a routine of the same name and arguments > either have to share it type A = concept x p x B = concept x q x C = distinct int D = distinct int proc p(v: C) = discard proc q(v: D) = discard proc

Re: Bug with generic methods?

2017-09-04 Thread Udiknedormin
Well, for me the BEST "interfaces" would be explicit, namespaced concepts, actually (hello, Rust!). Please note the biggest problem of inheritance-based interfaces: you cannot add one to a type already in existence when you define the interface. Also, both interfaces and Nim's concepts are,

Re: Bug with generic methods?

2017-08-31 Thread Lando
> These are two models, inheritance and type classes, which are different > answers to the same problem. I can see no good reason to provide both in the > same language.. I see one difference: with concepts the type match is an implicit one, the person creating the matching concrete type

Re: Bug with generic methods?

2017-08-29 Thread LeuGim
> this language claims to be rather minimalistic does it?

Re: Bug with generic methods?

2017-08-29 Thread Udiknedormin
It seems to me that concepts' vtables make methods obsolete. These are two models, inheritance and type classes, which are different answers to the same problem. I can see no good reason to provide both in the same language if this language claims to be rather minimalistic. Also, vtables give

Re: Bug with generic methods?

2017-08-29 Thread Lando
> At least Nim would have to instantiate all methods that could be called at > runtime. I see. Calculating the minimal set of necessary method instances at compile time looks hard-to-impossible to me though, at least with multiple-dispatch methods. > I think there were suggestions about

Re: Bug with generic methods?

2017-08-29 Thread Lando
Thx for your answers guys. @def: Does that mean that in order to make methods work with generics, Nim would have to be able to instantiate methods for generic parameters after dynamic dispatch (at runtime)?

Re: Bug with generic methods?

2017-08-28 Thread def
That's obviously supposed to work and it's a bug when using methods in combination with generics. Without generics it works fine: type Console* = ref object of RootObj ViewportConsole* = ref object of Console method draw*(self: Console, engine: string) =

Re: Bug with generic methods?

2017-08-28 Thread Lando
Probably an [object variant](https://nim-lang.org/docs/manual.html#types-object-variants). Or maybe wait until concepts are implemented.

Re: Bug with generic methods?

2017-08-28 Thread Lando
That's because of the sequence. If you would store the objects in two separate sequences for _Console_ and _ViewportConsole_ instead, you would get the expected result. Apparently, _var consoles: seq[Console]_ sets the runtime type of the elements to **exactly** _Console_.

Bug with generic methods?

2017-08-27 Thread 10c8
types, but it seems to be only calling the base one. It only calls the ViewportConsole implementation if I explicitly cast **console**. Is that a bug with generic methods, or am I doing this the wrong way? I was storing a reference to an **Engine** in the **Console** itself before, but **Engine