WurstStdlib2 icon indicating copy to clipboard operation
WurstStdlib2 copied to clipboard

Adapt StdLib to new typeclass features

Open peq opened this issue 5 years ago • 3 comments
trafficstars

Trying out how rewrite of StdLib with new generics and type classes would look like (see https://github.com/wurstscript/WurstScript/pull/931).

Feedback and tests with users of the library are very welcome.

peq avatar Feb 12 '20 22:02 peq

As mentioned I'm not too big of a fan of public implements as it sounds wrong. implementation or trait are probably more suited. Regarding ConvertIndex since it's more a property/trait shouldn't it be Indexable?

Frotty avatar Feb 14 '20 19:02 Frotty

Probably it's performance-wise better to introduce a typeclass with methods to write and read the type to/from the native hashtable, so it would be possible to use HashMap with native types and strings without any overhead, as they would use their own methods, like saveString, loadString, etc.

rhazarian avatar Feb 21 '20 17:02 rhazarian

Yes, that's a good idea. Just have to figure out how to do this so that it's not necessary to implement two type classes for every type that does not have a hasmap native.

peq avatar Feb 21 '20 17:02 peq