News for hackers. Stuff that matters.
Re:Ask HN: 30y After 'On Lisp', PAIP etc., Is Lisp Still "Be... by kazinator on Saturday June 08, 2024 @10:01PM (#40621484)
The syntax of + and - is rigid in C++, but functions can be written to extend it. This is not new; you are making claims that were not true in the first ISO C++ in 1998, or its predecessors revisions going quite far before that.

When a is a class type (and more recently this is now supported for enumerations also) then the surface syntax a + b means the same thing as a.operator+(b): invoking the operator + member function of a with argument b.

Re:Ask HN: 30y After 'On Lisp', PAIP etc., Is Lisp Still "Be... by Turing_Machine on Saturday June 08, 2024 @11:41PM (#40621851)
> functions can be written to extend it.

Unless I'm mistaken (which I may well be), you can't do that at runtime, only at compile time.

Re:Ask HN: 30y After 'On Lisp', PAIP etc., Is Lisp Still "Be... by kazinator on Monday June 10, 2024 @09:15PM (#40641208)
I replied to this not knowing exactly where the goalposts are.

Indeed, in C++, our a + b expression is statically analyzed to be working with specific types; the declared types of a and b. When that code is compiled, it will work with no other types.

However, if we anticipate that kind of extension, we can have a be a reference to some numeric_base class where operator + is a virtual function.

With some help from a bit of platform specific coding, we can have dynamically loaded modules which can provide new classes derived from numeric_base that ca be passed to existing code in the program which uses + on numeric_base.