Why not use operator overloading?
( Rx.Rx("[ \t\n\r\f\v]") | Rx.Rx("//[^\n]*\n") | Rx.Rx("/\*([^*]|\*[^/])*\*/") ) * Rx.inf
Well, I think your example shows one reason: It's then necessary to introduce objects on the leaf level instead of higher up. Assuming that there are about as many leaves in the syntax tree as inner nodes, little is gained when it comes to brevity.
Also much is lost in general ease of use; the author would often have to spend time brooding on the operator bindings and the technical details on how magic objects like Rx.inf works. The reader must then do the same too. So it's essentially only unnecessarily tricky to write and unnecessarily tricky to read. Better to stick to the plain old boring easy and obvious function syntax instead.
I abhor overuse of overloaded operators in general. More often than not, it only becomes a mild form of obfuscation, like a little puzzle. It carries the same kind of fascination too: "Hey, look how odd I can make my code look!" - "Whoo, cool!" Certainly fun when making short code snippets to show off with, but not something I'd like to meet in everyday code.
Operator overloading is good when making data types that should work like the builtins in some aspects since it helps keeping a consistent interface, but that's it. It's definitely a feature that the type restrictions limit `< to comparisons like the builtin operator.
/ Martin Stjernholm, Roxen IS
Previous text:
2003-09-22 22:53: Subject: wish: string with other quoting then \
Why not use operator overloading?
( Rx.Rx("[ \t\n\r\f\v]") | Rx.Rx("//[^\n]*\n") | Rx.Rx("/\*([^*]|\*[^/])*\*/") ) * Rx.inf
Btw, I tried doing this to emulate pipes recently, and found out that I can't make an `< operator which returns an object.. Kind of annoying as I wasn't planning to use `< for comparisons.
I was trying to do something like:
( Cmd("grep foo") < Stdio.File("foo.txt") | Cmd("uniq") > mysocket ) ->run();
Any ideas for how to get around the type restrictions in `< and other lfuns?
/ Fredrik (Naranek) Hubinette (Real Build Master)