[fpc-pascal] Custom operator

Mr Bee pak.lebah at yahoo.com
Sun Feb 2 03:59:40 CET 2020

Of course precedence of the operator also must be informed by the operator author to the compiler in some ways. Operator has different purpose and workflow from function/method. If not, then everything can be just a method, no operator needed.
However, if this is not practically possible in FPC, it’s all right then.
Thank you.

–Mr Bee

    Pada Minggu, 2 Februari 2020 08.32.23 WIB, Sven Barth via fpc-pascal <fpc-pascal at lists.freepascal.org> menulis:  
 Mr Bee via fpc-pascal <fpc-pascal at lists.freepascal.org> schrieb am So., 2. Feb. 2020, 02:11:

Hi all,
Besides overloading available operators, could we make our own custom operator(s) in FPC?
For example, I want to use ∑ to sum array values? Also other Unicode characters such as ≥, ≤, ±, ≠, etc as custom operators? I think such feature is important in this unicode era.
Is it possible?

No, it is not (okay, technically, in theory it would be possible, but definitely not desired). The compiler would need to know such operators so that it can determine the precedence. You can just as well use methods/functions for that with the added benefit that they can be named in a way that explains their purpose. 
Regards, Sven 

fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200202/9126fca8/attachment.html>

More information about the fpc-pascal mailing list