WurstScript icon indicating copy to clipboard operation
WurstScript copied to clipboard

Cannot destroy objects of type T

Open Cokemonkey11 opened this issue 4 years ago • 4 comments

Is this something that new generics can help with?

Cokemonkey11 avatar Mar 08 '21 22:03 Cokemonkey11

Yes, the way that I would imagine it is:

  • there would be a type class for destroyable types
  • in a function foo<T: Destroyable>(...) you would be able to destroy objects of type T. Similar for classes.

Workaround for current Wurst: Without type classes, you could pass a destroy function as a parameter.

peq avatar Mar 09 '21 22:03 peq

Thanks @peq. I wonder if it makes sense to implement destroy for native types with no-op, so that destroy is globally implemented trait. That would be a nice stop-gap before new generics

Cokemonkey11 avatar Mar 12 '21 23:03 Cokemonkey11

That would not help without new generics. With current generics, T is erased and there is just an int. So destroy would always be a no-op for generic types, which would be very confusing.

peq avatar Mar 13 '21 11:03 peq

So @peq, your new job is very boring and you will definitely spend some time on wurst soon, right? 🙃

Cokemonkey11 avatar Mar 15 '21 21:03 Cokemonkey11