hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.56k stars 248 forks source link

[SUGGESTION] Changed operators meanings in CPP/2 limits the power of CPP/2 #912

Open jhruby opened 11 months ago

jhruby commented 11 months ago

I feel that the new behavior for operators such as:

i++ returns the same value is in CPP/1 ++i and adding obj- as moving object feels weird to me and raised concert about future of libraries that highly rely on operator overloading.

I really like Boost.SpiritX3 library when you can define grammar by overloaded operators and I really think that this is the power of CPP/1 that I'd like to not to loose.

For moving from object I'd prefer something more clear like move keyword. It would be also better for text search.

Anyway continue with the great work looking forward for the future :]

ntrel commented 10 months ago

i++ returns the same value is in CPP/1 ++i

I think this is a gotcha when porting Cpp1 code to Cpp2. A good rule of thumb would be not to redefine Cpp1 expressions to mean somthing else in valid Cpp2 code.

adding obj- as moving object

Are you sure? The syntax is (move expr) in regression_tests.

Xeverous commented 5 months ago

x++ returns new value in new C++ so it still can be meaningfully overloaded. I use Spirit X3 and I don't see any value I would lose. There will be 1 less operator to overload but I don't remember being it utilized in the library DSL.