> On Jun 7, 2019, at 4:56 PM, Sven Barth via fpc-devel > <fpc-devel@lists.freepascal.org> wrote: > > Because I don't want to open the can of worms that is going to be overloading > the postfix "operator". People are going to abuse the hell out of it (they > will with default properties as well, don't get me wrong there), making the > language much harder to read. Nowadays you can rely on the "." denoting some > sub element. With operator overload using a "." could mean triggering some > credit card payment (I'm exaggerating here, but this would technically be > possible).
The default properties are a much bigger can of worms. That’s why I suggested the operator overload. With default properties you can do this: ====== var rec: TMyRecord<TObject>; // assume TMyRecord has a default property to a field with TObject begin // assignment operator overloads rec := TObject.Create; // classref access writeln(TMyRecord.ClassName); // all statements, with, while, if, for etc... with rec do ; while rec do ; // postfix, fields and function overloads rec.Free; // all binary AND unary overloads if rec = nil then ; end. ===== All the postfix operator allows is “.” access. That’s like 90% less intrusion into the compiler. Much smaller can of worms. Sorry C++ had the smarter idea here. Limit the access to “.” and if the user wants assignments or equality etc… they overload other operators. Please tell me how that’s a bigger can of worms. Regards, Ryan Joseph _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel