[fpc-pascal] Feature proposal: function-based assignment operators

Xiangrong Fang xrfang at gmail.com
Fri Mar 29 03:03:22 CET 2013


2013/3/29 Sven Barth <pascaldragon at googlemail.com>

> There was already a discussion some time ago whether we should allow
> operators like "or=" and such as well and the result was simple: no. I
> consider this the same here.
>
> You can achieve a similar effect through type helpers in 2.7.1 though:
>

Using type helper here may result in "apparently" same effect. But in fact
they are very different.  The syntax OP proposed is a mechanism of the
language (compiler), i.e. support will be ubiquitous, but if you implement
it with type helper, then you have to write the helper (or use it) every
time you need such very tiny "feature" (if not just save typing), which
voids the whole idea of make the source code simpler.  Unless you put such
helper into the RTL, which will be similar to the OP's proposal, but not as
elegant.

My opinion is that I like this feature, but I don't mind if it is
implemented or not. That will indeed make the syntax more complex and a
little un-pascal-ish.

As to the C-style += operator, I have one question, will it makes code
slightly faster? because if you use Inc() or Dec() there will be a function
call?  or, the compiler will always try to inline Inc or Dec?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20130329/ddb7d64d/attachment.html>


More information about the fpc-pascal mailing list