bcc icon indicating copy to clipboard operation
bcc copied to clipboard

Define Enums in Types

Open GWRon opened this issue 5 months ago • 3 comments

Coming from https://skirmish-dev.net/forum/topic/218/libsgd-with-lua/32 where "DruggedBunny" is writing a wrapper/translator of Mark Siblys LibSGD for BlitzMax ... there came up a discussion about enums in classes - and the visibility of enum "elements" inside of their file-scope. (so accessing an element of an enum without the enum-name and thus requiring "full names" of the enum elements while we in Blitzmax need to use the enum name itself in addition - as usual for us :D)

So is there a reason to not allow enums in a Type for "namescoping" them?

SuperStrict
Framework Brl.StandardIO

Enum ETest
	A
	B
End Enum

Type TTest
	Function T()
		SubT()
		Function SubT()
			print "hello world"
		End Function
	End Function
	
	Enum ETestTest
		A
		B
	End Enum
End Type

The idea there seems ot be that you can have your "all in one class" as name scope container (for SGD it would be Type SGD) and to be able to access enums with that scope (SGD.EMyEnum).

While I brought up the module scopes:

import SGD.core
Local e:SGD.core.EMyEnum = SGD.core.EMyEnum.A

it is of course not the same (eg the ".core" is required as the second level module is mandatory).

Maybe we could achieve something like the desired one without enums in types - but maybe not. What do others think about that and potential limits, issues, ... benefits? @woollybah @HurryStarfish

GWRon avatar Sep 25 '24 06:09 GWRon