Concatenation Operators in Unimperative

The Unimperative language I posted about nearly a year ago has been reborn as a "concatenative" language, ala Joy. ( personally I would prefer to call it a compositional language, but who am I to buck trends ).

The Unimperative language is also a tiny subset of C++, so I am trying to decide on the concatenation operators. Currently I support separate left-concatenation (f << g == f . g) and right-concatenation (g >> f == f . g). In the end this gets a bit clumsy, and I find hard to read. So I want to overload the comma operator.

My question is this: which concatenative form (left or right) should the comma overload to? In other words should I treat it as a left to right sequencing operator, or as a composition operator?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


f, g reads to me as "first f, then g". If you would have asked what would be the best character to use as a sequencing operator, I would have said "," (or ";").


You are right, it is obvious. Weird thing, is that when you stare at too many different ways of doing things, your mind plays tricks on you and the obvious has a way of hiding.

Forget all the silly ">>" and "<<" I think I will support just two forms:

def<> h = g, f;

and its partner:

def<> h = f(g);

Choosing operators in C++

C++ operators have fixed precedences. "." has the highest precedence, but "," has the lowest precedence. I think it is more important that the appearance.

Another consideration is whether the overloaded operators confuse to the original meanings. Overloading "()" is not the best choose, since it can be confused with the usual function call.

However, if it is not required to be a "tiny-subset of C++", you can simply create two new operators, and choose the operation much more freely.