Strict - Not Cross-platform!

Monkey Forums/Monkey Programming/Strict - Not Cross-platform!

therevills(Posted 2011) [#1]
Just something to watch out for when using Strict.

When using Strict you need to put in a return type for all your methods and functions even if its just Void.

So I started my game in HTML5 - the easiest target... so I had:

Strict
Import mojo

Global app:MyApp

Function Main:Void()
	app = New MyApp()
End Function


Class MyApp Extends App
	Method OnCreate:Void()
	End Method

	Method OnUpdate:Void()
	End Method

	Method OnRender:Void()
	End Method
End Class


Works fine in HTML5... so I tried Android and got return type errors. So I had to change them to:

Strict
Import mojo

Global app:MyApp

Function Main:Void()
	app = New MyApp()
End Function


Class MyApp Extends App
	Method OnCreate:Int()
		Return 0
	End Method

	Method OnUpdate:Int()
		Return 0
	End Method
	
	Method OnRender:Int()
		Return 0
	End Method
End Class


Now I have just tried the above code for GLFW (Windows) and got another return type error... this time on the Main function...

So hopefully this is totally crossplatform:

Strict
Import mojo

Global app:MyApp

Function Main:Int()
	app = New MyApp()
	Return 0
End Function


Class MyApp Extends App
	Method OnCreate:Int()
		Return 0
	End Method

	Method OnUpdate:Int()
		Return 0
	End Method
	
	Method OnRender:Int()
		Return 0
	End Method
End Class



MikeHart(Posted 2011) [#2]
Thanks for the info.


John Galt(Posted 2011) [#3]
Thanks for the heads up. It would be nice if Monkey would do the necessary behind the scenes so you don't have to add these return values.


OvineByDesign(Posted 2011) [#4]
This is the same for the Iphone build, its just caught me out.


Amon(Posted 2011) [#5]
Thanks for the info.