Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user-defined operators in C++

Tags:

c++

operators

What do you think about an imaginary possibility to specify user-defined operators in C++.

Such user-defined operator could be defined by operator name (arbitrary sequence of allowed chars?), its precedence, associativity and arity (something else?).

They could be used for many purposes: to help to build "tiny" DSLs over C++, for list comprehension etc.

Wouldn't this feature extend the language possible usage? What are other languages that allow user-defined operators? Lisp comes to mind, anything else? Any links about the topic?

like image 730
Andriy Tylychko Avatar asked Feb 26 '11 23:02

Andriy Tylychko


1 Answers

Well, you know, Bjarne Stroustrup did propose such a thing...Generalizing Overloading for C++2000. :-P :-P :-P

like image 88
Chris Jester-Young Avatar answered Oct 04 '22 03:10

Chris Jester-Young