I'm in love with Ruby. In this language all core functions are actually methods. That's why I prefer postfix notation – when the data, which I want to process is placed left from the body of anonymous processing function, for example: array.map{...}
. I believe, that it has advantages in how easy is this code to read.
But Mathetica, being functional (yeah, it can be procedural if you want) dictates a style, where Function name is placed left from the data. As we can see in its manuals, //
is used only when it's some simple Function, without arguments, like list // MatrixForm
. When Function needs a lot of arguments, people who wrote manuals, use syntax F[data]
.
It would be okay, but my problem is the case F[f,data]
, for example Do[function, {x, a, b}]
. Most of Mathematica functions (if not all) have arguments in exactly this order – [function, data]
, not [data, function]
. As I prefer to use pure functions to keep namespace clean instead of creating a lot of named functions in my notebook, the argument function
can be too big – so big, that argument data
would be placed on the 5-20th line of code after the line with Function call.
This is why sometimes, when evil Ruby nature takes me under control, I rewrite such functions in postfix way:
Because it's important for me, that pure function (potentially big code) is placed right from processing data. Yeah I do it and I'm happy. But there are two things:
- this causes Mathematica's highlighting parser problem: the
x
in postfix notation is highlighted with blue color, not turquoise; - everytime when I look into Mathematica manuals, I see examples like this one:
Do[x[[i]] = (v[[i]] - U[[i, i + 1 ;; n]].x[[i + 1 ;; n]])/ U[[i, i]], {i, n, 1, -1}];
, which means... hell, they think it's easy to read/support/etc.?!
So these two things made me ask this question here: am I so bad boy, that use my Ruby-style, and should I write code like these guys do, or is it OK, and I don't have to worry, and should write as I like to?