Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: levi@localhost.nc3a.nato.int
Subject: operators pow and **
Date: 14 Dec 2000, 21:11:39
Frank Heckenbach a écrit :
>
> Maurice Lombardi wrote:
> > It seems that operators pow and ** cannot be redefined in gpc. Is that expected ?
>
> No, they should be. I think adding them in
> parse.y:operator_identifier should do the trick, but there's a
> comment stating exactly that this "is unnecessary". Seems it is
> necessary, but since I don't know the real meaning of this comment,
> I'll leave this to Peter... (maur7.pas)
With today snapshot (20001214) pow and shl work as expected, but ** compiles but fails when using it
with a message:
operatordemo.pas: In function `pascal_main_program':
operatordemo.pas:49: left operand of `**' must be of integer, real or complex type
The test program is just an expansion of operatordemo:
------------------------------------------------------
program OperatorDemo;
type
Vector3 = record
x, y, z: Real;
end;
var
a, b, c: Vector3 = (1, 2, 3);
operator + (u, v: Vector3) w: Vector3;
begin
w.x := u.x + v.x;
w.y := u.y + v.y;
w.z := u.z + v.z;
end;
operator pow (u: Vector3; v: integer) w: Vector3;
begin
w.x := u.x pow v;
w.y := u.y pow v;
w.z := u.z pow v;
end;
operator shl (u: Vector3; v:integer) w: Vector3;
begin
w.x := round(u.x) shl v;
w.y := round(u.y) shl v;
w.z := round(u.z) shl v;
end;
operator ** (u: Vector3; v:real) w: Vector3;
begin
w.x := u.x ** v;
w.y := u.y ** v;
w.z := u.z ** v;
end;
begin
c := a + b ;
writeln(c.x,' ',c.y,' ',c.z);
c := a pow 3;
writeln(c.x,' ',c.y,' ',c.z);
c := a shl 2;
writeln(c.x,' ',c.y,' ',c.z);
c := a ** 2.5; (* WRONG *)
writeln(c.x,' ',c.y,' ',c.z);
readln;
end.
------------------------------------------------
Hope this helps
Maurice
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Maurice Lombardi | operators pow and ** | 13 Dec 2000, 12:17:50 |
| Frank Heckenbach | operators pow and ** | 14 Dec 2000, 14:51:36 |
Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.
Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.
This page was created by Crystal 0.999 (Linux 2.4.27/i686).