Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-01

Operator overloading with Text labels or words

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lars

It's not possible to define an operator like:

Operator AbcXyz(r : real; z1 : complex) z : complex;
begin
end;

Is it?

Has to be a symbol?

If one could use words or text as operators this might be very interesting, although, probably a double edged sword like Lisp where you could embed programming languages inside programming languages.

For example:

  x := 4 PLUS 4;
  writeln(x);

Prints 8..

Operator Plus(...);
begin
end;

So you just invented Cobol inside fpc or something like cobol. Bad example..

Michael Van Canneyt
to Lars

Hi,

You can use words.
But only words that the compiler defines. See the documentation.

Michael.

Lars wrote 31 lines
It's not possible to define an operator like: Operator AbcXyz(r : real; z1 : complex) z : complex; begin end; Is it? Has to be a symbol? If one could use words or text as operators this might be very interesting, although, probably a double edged sword like Lisp where you could embed programming languages inside programming languages. For example: x := 4 PLUS 4; writeln(x); Prints 8.. Operator Plus(...); begin end; So you just invented Cobol inside fpc or something like cobol. Bad example.. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal