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?
Thank you.
Regards,
–Mr Bee
Mailing lists / fpc-pascal / 2020-02
Custom operator
3 messages · 2 people ·
- MMr Bee 2
- SSven Barth 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Mr Bee via fpc-pascal schrieb am So., 2.
Feb. 2020, 02:11:
Show quoted text 11 lines
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
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 menulis:
Mr Bee via fpc-pascal 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
