Language Questions

Monkey Forums/Monkey Programming/Language Questions

maltic(Posted 2012) [#1]
I have a few questions regarding the monkey language:

1. I like the Monkey supports generic programming. However it seems I can't write specified generics of the form "<T implements I>" or "<T extends E>". If so, why? Generics are determined at compile time, not runtime, so there isn't any need for monkey's target languages to support this (even though most do, I think). Also, are there any good workarounds? Has anyone tried using reflection to get around this? Is it a feature Mark might add in the future?

2. Is there any way to get a function pointer, or fake lambdas outside of creating every function as an object wrapping a method?

3. So I can't define arbitrary dimension arrays right? Is the best solution just defining my own generic constructor for every dimension?


Gerry Quinn(Posted 2012) [#2]
As I understand it, the answers to all your questions is no at the moment.

If you can use anything more than one plain 'T' in generics, it has not been widely advertised, and as far as I know you are stuck with workarounds for function pointers too.

I created templates for allocating arrays up to 4D, and I haven't needed to go beyond 3D so far. If I do, I guess I'll have to make use of the primitive form of template metaprogramming known as 'cut and paste'. ;-)


maltic(Posted 2012) [#3]
As I understand it, the answers to all your questions is no at the moment.

If you can use anything more than one plain 'T' in generics, it has not been widely advertised, and as far as I know you are stuck with workarounds for function pointers too.

I created templates for allocating arrays up to 4D, and I haven't needed to go beyond 3D so far. If I do, I guess I'll have to make use of the primitive form of template metaprogramming known as 'cut and paste'. ;-)



Ah I thought so. Good tip with the cutting and pasting haha. At least I can automate cut and pasting with sublime text--its almost like real metaprogramming!