Final classes have virtual methods (c++)

Monkey Forums/Monkey Bug Reports/Final classes have virtual methods (c++)

Shinkiro1(Posted 2013) [#1]
If a class is declared as final in monkey, trans shouldn't need to declare it's methods virtual in the translated file.
The thing is, a c++ compiler can't inline functions that are virtual (think of vector functions).

I know it may sound picky but maybe it's an easy fix?

PS: I have brought up the issue here before but I think it got deleted, would be nice if there could be an official word before that happens this time.


marksibly(Posted 2013) [#2]
Should be an easy fix, will take a look.


Erik(Posted 2013) [#3]
See also line 352 in cstranslator. (Virtual calls on XBOX are even slower than normal (global hashtable instead of vtable array)).

Local q$="public "
If decl.IsStatic()
	q+="static "
Else If decl.overrides And Not decl.IsCtor()
	q+="override "
Else ' If Not decl.IsFinal <------- Should this be here???
	q+="virtual "
Endif

Emit q+t+"{"
EmitBlock decl
Emit "}"



marksibly(Posted 2013) [#4]
The latest develop branch code at github contains an aggressive fix for this - it will only use 'virtual' when absolutely necessary, and declare methods final/sealed whether or not they are declared as such if they are not overridden.

> Virtual calls on XBOX are even slower than normal (global hashtable instead of vtable array)

I've heard this before somewhere but haven't seen any official/technical mention of it - do you have a link?


Erik(Posted 2013) [#5]
Great, thanks!

I am pretty sure this still applies.
http://blogs.msdn.com/b/netcfteam/archive/2005/05/04/414820.aspx