Lists of types?
Community Forums/Monkey Talk/Lists of types?| 
 | ||
| What is the format for a list<t> in monkey? | 
| 
 | ||
| if you want to create a new list class wizard end class local mylist:List<wizard>=new List<wizard> monkey is ultra strict and case sensitive so it has to be List with a capital L only one kind of class is allowed per list Last edited 2011 | 
| 
 | ||
|  only one kind of class is allowed per list Although that would include any class that extends wizard. | 
| 
 | ||
| argh it was that bloody local keyword again! gets me every time. I dont understand why it is needed to be honest. | 
| 
 | ||
|  I dont understand why it is needed to be honest. Simply for readability, I think. Let's say I decided to use a static iterator in a particular method, well six months on when I come back to the code and don't see the Local keyword in the For...EachIn loop I'll immediately realise what I did. | 
| 
 | ||
| S'pose... but to be honest i have no idea why Mark chose: Local a:int over: int a I suppose it is to be maxlike but i always wondered that about max too to be honest. in my world "more wordy != easier" :D | 
| 
 | ||
|  in my world "more wordy != easier"  Take that to its logical conclusion, though, and you end up with C! Hmmmm... BlitzC :D | 
| 
 | ||
| C-like syntax has some problems with the grammar once you try to make it more complicated than C itself (C++ is famous for this). Don't know how much Mark is into the theoretical stuff but language designers don't usually like that sort of thing. Also, am I imagining things or did I read somewhere that you could do this: Local mylist := new List<wizard> Once you've got types with multiple parameters nested three deep and suddenly realise you need to make a change, that could get useful. | 
| 
 | ||
| only one kind of class is allowed per list Well, that's not true. You can always use a 'generic' Object class, but this is a question of design of your application/code. | 
| 
 | ||
| Also you can add child objects to a superclass's list: | 
| 
 | ||
| Thanks for the infos although sledge/yasha i dont want -C- ...just standard declaration syntax. (BIG difference :D) by the way, what is monkey's line separator, why does it crash when i stick a ; on the end (its an ingrained habbit for me from all the other langs i use. Max was good because it was treated as a separator so it could be there or not, the compiler did not care. | 
| 
 | ||
| Monkey's line separator is just <return>: If Player.x > 100 And Player.y < 100 Then Player.dead = true EndIf Yeah its a shame about the semi-colon - I would have liked if you needed to put it on every line. | 
| 
 | ||
| Monkey's line separator is just <return>: About time, In C++ (notably) I liked spreading long parameter arguments down lines, as an example with a BlitzMax function: ImagesCollide( playerImage, player.x, player.y, player.frame, bulletImage, bullet.x, bullet.y, 0) I find that a lot betterer when wading across big lines of code. I know the semi-colon is handy though, that should be kept in too for multiple statements on one line. Dabz Last edited 2011 | 
| 
 | ||
| Two dimensional adhoc formatting is even better to read than assembler-like one dimensional code: ImagesCollide ( playerImage, player.x, player.y, player.frame, bulletImage, bullet.x, bullet.y, 0 ) Last edited 2011 | 
| 
 | ||
| Two dimensional adhoc formatting is even better to read than assembler-like one dimensional code Nah, me no likely... Ultimately, its a horses for course thing! Dabz | 
| 
 | ||
| I prefer the vertical style too (unless they all fit reasonably on one line) it is easier to look at. Not sure where "assembler-like" fits in though :D Last edited 2011 |