pcomb icon indicating copy to clipboard operation
pcomb copied to clipboard

Operator overloading for basic combinators

Open nicola-gigante opened this issue 9 years ago • 1 comments

Hi,

It would be nice to have operator| and operator+ as a shorthand for alt and seq. Has it not be done already by design? The many combinator could also be aliased by unary operator*, as in Boost.Spirit, but that's a bit more controversial since the standard syntax would be a postfix operator rather than prefix.

In any case, very well done library!

nicola-gigante avatar Feb 04 '17 12:02 nicola-gigante

Thank you for the comment!

Honestly speaking, I never thought this repo would draw interest from anyone other than myself, so I didn't put a lot of thoughts on ergonomics of the APIs. For my personal uses, I could live with seq, alt and many just fine, but I agree that operator| and operator+ could make the client codes much terser.

Off the top of my head, adding those overloads should be a fairly simple task. I'll try to do it when I got some time to spare. Again, I appreciate your suggestion.

Personally I don't quite like the pervasive uses of operator overloading in Boost.Spirit. Changing the meaning of unary * is also something that I try to avoid, as for my taste the readability improvement of it doesn't seem to justify the confusion it may potentially cause.

grievejia avatar Feb 04 '17 23:02 grievejia