End or End Method?
Monkey Forums/Monkey Programming/End or End Method?
| ||
I am new to Monkey and thought I give it a go. I am choosing to use TextMate as my text editor (thanks Matt). Code folding works if I use the "Method...End Method" form but does not work with the "Method...End" form. Monkey seems to work either way. Is there a difference between forms and is one being depreciated? |
| ||
There's no difference. Don't know if the longer method is deprecated but that's how I do it as it makes code more readable. |
| ||
I actually prefer just "End" ;) Monkey accepts the following: * End * * End Method Which IMHO is too many... it should only allow one not |
| ||
It's a code stylistic choice. Also, Monkey doesn't allow "EndMethod." It throws an error for me. Unless that's a bug. |
| ||
Opps yeah you are right... I was thinking of BlitzMax and the IFs. Monkey accepts the following closing commands for IFs: * End * EndIf * End If |
| ||
AFAIK None is deprecated. I preffer the longer form when I don't have to type it all, as it makes code clearer to me. |
| ||
Thanks all. Although it is a bit more typing I will stick with the longer form as it seems more 'proper' somehow and code folding works in TextMate. |
| ||
I also think it makes code clearer to me. |
| ||
as it seems more 'proper' Since I code mostly in Java at work I find it less "proper" ;) In Java "}" is used for "End" for Ifs, Loops, Classes, Methods etc: Class Foo { private int x; public void setX(int x) { if (x < 10) { this.x = 0 } else { this.x = x } } } |
| ||
LOL! since it's a derive from basic(?) and we have stuff like this: repeat /until, while/wend, for/next to me it makes since to follow it with it's corresponding counter part. |
| ||
since it's a derive from basic(?) and we have stuff like this: Yeah that's fine... but lets have one ending for them not two or three: While .. Wend While .. End For .. Next For .. End If .. End If If .. EndIf If .. End Method .. End Method Method .. End Function .. End Function Function .. End I believe that programming languages should be concise as possible... |
| ||
I agree with that! |
| ||
The chances of me going through thousands of lines of code and adding redundant keywords that serve no purpose other than to make it look "more BASIC-y" in some people's eyes is slim to none. |
| ||
Ah, I really like the flexibility; something not frequently offered by many programming languages. I do choose the Method/Function... End construct in Monkey personally (while much preferring Select/End Select, etc), which I seem to recall I wasn't too happy with at first, but, programming something in BlitzMax with an eye on Monkey portability, I'm finding BlitzMax's enforced End XYZ slightly annoying now! Seriously, though, you can take your pick. That's a good thing, within reason. |
| ||
LOL! I guess the fix won't be a fix for all solution. Whatever side Mark decides to go, if he goes, I won't complain. my way is as simple as search and replace others not so simple. |
| ||
I think Mark has already decided - Its too late to change Monkey now... @DruggedBunny, that's one of the reasons why I am coding a BlitzMax target for Monkey ;) |
| ||
Just be thankful you aren't forced to use whitespace to declare your blocks like a certain other language... |
| ||
since it's a derive from basic(?) and we have stuff like this: Monkey is derived from BASIC, in the same sense that an F-22 Raptor is derived from a bicycle. Yes the Wright brothers where bicycle repairmen, and yes they did invent the first vehicle capable of sustained, powered, heavier-than-air flight. But that's really where the similarities end. Monkey today has much more in common with more modern languages like Java and Python, than it does with BASIC. Just be thankful you aren't forced to use whitespace to declare your blocks like a certain other language... Except that would be awesome, and I definitely think think BRL should take more pointers from Python (or Boo or other YAML-like languages), and less (much less) pointers from languages like Lua for instance (which also erroneously thinks it's a fantastic idea to have different keywords delimit the end of block statements). |
| ||
...languages like Lua for instance (which also erroneously thinks it's a fantastic idea to have different keywords delimit the end of block statements). Last I checked, blocks in Lua always ended with "end" (except "until"). |
| ||
I've become so used to the database language we use at work that uses "End For" and "End While" instead of "Next" and "Wend" that I use it in monkey too....now all my "For" loops end with "End For" (which looks neater to me than "Next"....I was so used to really old basic that for a long time with blitz I used to put the iterator variable after the next which was always disallowed ... eg "For i = 1 to 3 .... some statements ..... Next i" |
| ||
I use "End If" and "End Method", it keeps my fingers from cooling down too much while thinking about the next line of code! |