About Monkey 2 › Forums › Monkey 2 Development › #region
This topic contains 7 replies, has 5 voices, and was last updated by
cocon 2 years, 3 months ago.
-
AuthorPosts
-
January 5, 2017 at 8:36 pm #6233
How about a “#region” feature that it will create some sort of organization of the code base into logical groups (not source code groups). It will be pretty much useful only in the IDE.
Perhaps if there is no point to nag the parser about this, then at least this workaround could be used:
Monkey12#rem region#endIf nerobot reads this would decide about this, I just throw the idea.
January 5, 2017 at 9:11 pm #6234? what for ?
If you need to split a single file into separate regions then its probably about time you, split the code into separate files, considering putting suitable code together in a class, etc….
January 5, 2017 at 10:46 pm #6235Not that a file should be humongous, but it leads to a good habit of making clear cuts among the code from the start.
Monkey123456789101112131415161718192021222324252627282930313233343536373839404142434445464748Class Level#region MediaField SpriteSheet:ImageMethod LoadSpriteSheet()EndMethod DrawSpriteSheet()End#end#region TilesetField Tiles:Tile[]Method LoadTiles()End#end#region CoordinatesField AnchorPoint:Vector2Field Size:Vector2#end#region CheckpointsField CheckPoints:Vector2[]Method LoadCheckPoints()End#endEnd' VS 'Class LevelField SpriteSheet:ImageField AnchorPoint:Vector2Field CheckPoints:Vector2[]Field Size:Vector2Field Tiles:Tile[]Method LoadSpriteSheet()EndMethod DrawSpriteSheet()EndMethod LoadTiles()EndMethod LoadCheckPoints()EndEndPerhaps you might do a counter offer to split the code into sections with standard comments.
Monkey123456789101112Class Level' Tileset _______________Field Tiles:Tile[]Method LoadTiles()End' _______________________' Coordinates ___________Field AnchorPoint:Vector2Field Size:Vector2' _______________________EndWell, it does the trick in some sort of old-school approach, however the real difference with regions is that you will standardize this principle (of separating the code into sections) by design, rather than doing ASCII art.
January 6, 2017 at 12:20 am #6236Its just swapping one ascii soup for another, I just don’t see the point…
January 6, 2017 at 12:30 am #6237@codifies #Regions are foldable. I personally find them quite useful, but that’s a matter of taste. They are supported by Jungle and Mollusk.
January 6, 2017 at 3:35 am #6239This time Ted2go’s parser is based on mx2cc. When (and if) I will add an additional parsing of local scopes and add foldings.. then we can get this. Folding in editor and in code tree.. dreams
Maybe via comment like this:
‘#region
‘#end
January 6, 2017 at 10:49 am #6242Yes, that would be amazing.
+1January 7, 2017 at 10:42 am #6274nerobot: If Mark doesn’t want to mess the parser further with other additions, this approach ‘#region would work. Let’s see about it in a few months from now.
-
AuthorPosts
You must be logged in to reply to this topic.