private function myFunc():Void {
if (condition) {
// implementation here
}
}
private function myFunc():Void
{
if (condition)
{
// implementation here
}
}
I believe that loosely, the first was created by the inventor of C (there are variations as well on whether else's are inline with the bracket, and whether single expressions use brackets or not, but that still fits your first example).
Personally, I prefer #1 as it looks prettier to me, less rigid, and it wastes less space, there being no content you might wish to add into the blank spaces, I see little reason to place them there. For readability sake I would rather inject blank lines where I feel a distinction is necessary inside my blocks.
That's just my opinion though, and I used to prefer #2, I think it's mostly just a matter of what looks nicer to you, most of the supposed benefits of different styles are just justification for people liking their own style.
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
Hej,
In Haxe all is a block "{}".
//if( condition )
{
...
}
So writing like that, we can easily comment just the line where
the "if" is and so the block is executed...
But I think it's a question of personal feeling
if (condition)
setCallbackArray( [ function(e) {
someMoreCommands();
someMoreCommands();
}]);
if (condition)
{
setCallbackArray(
[
function(e)
{
someMoreCommands();
someMoreCommands();
}
]
);
}
I prefer the first, indent is enough for me and seeing the "header" (function, if, for...) as the last less-indented line gets better to me. And in languages like Python there is only indent. To each their own, I guess.
As for formatter, I am using astyle with somewhat tweaked settings for Java. It doesn't support Haxe and sometimes gets lost on things like inline metadata or other Haxe specific stuff, but it's good enough so far. I usually run it and then review changes with git add -p, which clearly doesn't scale, but so far it works for me...
js.
--
Take this: "readers of Lisp programs do not match parentheses, but use indentation."
;;; bad (defun f (x) (when (< (g x) 3) (h x 2) ) )
;;; good (defun f (x) (when (< (g x) 3) (h x 2)))
if (x)
{
}
if (x) {
}
if (a)
{
if (b)
{
if (c)
{
if (d)
{
}
}
}
}
if (a) {
if (b) {
if (c) {
if (d) {
}
}
}
}
if (a)
{
doSomeStuff();
}
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.
if( a ){
doStuff();
} else {
otherStuff();
}
function( a: String ): Bool {
return true;
}