# Ontology of Postfix Notation, Method Chaining, and Unix Pipe

By Xah Lee. Date: . Last updated: .

i just took 30 min walk and thought about this problem i had in mind vaguely for years. And, i have obtained clarity. I want to type it out here quickly as a record.

you know, how unix pipe can be considered as a postfix notation. For example, `a | b | c`.

now, Wolfram Language has a postfix operator. That is double slashes, `a // b // c` is equivalent to `c[b[a]]`, or to normal programing language notation of `c(b(a))`.

now, in ruby and JavaScript, we have method chaining. For example, `a.b.c`.

they are all postfix notation of some sort, but exactly what's the aspect, context, nuances? That is, i want to know the ontology.

so, walking and talking to myself, now i obtained clarity.

basically, the central thing we are interested is applying function sequentially, and a notation for it that's linear without nesting.

why do we want this? because:

• a linear notation is convenient to write. With nested notation such as `c[b[a]]` or lispy `(c (b (a)))`, you have to go to beginning and end back and forth for each new function.
• a linear notation is easy to read. With nested notation you have to dig into the inner most term first. Gets complex when function names themselves are nested expressions.

now, what's the deal with these terminologies: “postfix notation”, “unix pipe”, “method chaining”? in what way, aspect, or context, are they same or different?

now, remember the thing we want: “applying functions one after another and a linear syntax for it”. In this aspect, all of the above, Wolfram Language postfix notation, unix pipe, ruby JavaScript method chaining, all satisfy. So, yes, they are the same thing, as far as we are concerned.

now, the different terminologies emphasize different aspects or context. For example, “postfix notation” emphasize math background. Unix never called their pipe as “chaining function” or postfix notation, but again, it's just because the background and perspective are different. Unix shell called it pipe because the focus is on passing data around, as water flows thru a pipe. Similarly, math postfix notation isn't called piping, nor called method chaining. In math, which began as writting symbols on paper, with concepts of functions and operators, thus postfix notation.

one may still feel that we are forcing onto disparate things. To unify them, we can define a operator as postfix operator. The essence is that, it is left-side associative. That is, `a + b + c` means `(a + b) + c` not `a + (b + c)`.

(when we have `a . b` where the dot is a operator, written in function form it would be `f(a,b)`, and the semantic of the function is to take its second arg as function and apply it to the first arg, that is `f(a,b)``b(a)` )

So, in Wolfram Language, the `//` is a postfix operator. In unix shell, the `|` is a operator, and indeed it satisfies our postfix definition above. Similarly, in JavaScript, we consider the dot `.` to be a operator, and it also satisfies our postfix definition.

ontolog! clarity obtained!

Note: except that in JavaScript, when we have `a . b`, the `a` may just be a namespace, not object nor data. e.g. `Math.sin(3)`.