comp.lang.ada
 help / color / mirror / Atom feed
* Using a string as a binary operator
@ 2008-10-14 15:35 Joe
  2008-10-14 17:05 ` Dmitry A. Kazakov
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Joe @ 2008-10-14 15:35 UTC (permalink / raw)


Hey all,

I'm trying to build a simple stack the evaluates expressions in
postfix notation (i.e. "1 2 +").  I can't find a way to use the
operator directly when I get to it.  When I get to the  "+", but how
do I apply this string to 1 and 2?  The best I can do is make a case
statement that has a case for each binary operator, but this seems
very klunky.  I know you can write "+"(1,2) to return 3 but how do I
get Ada to recognize the string as an operator?  Here's a short
example of what I would like to do:

with Ada.Integer_Text_IO;  use Ada.Integer_Text_IO;
procedure Operators is
   Plus : String := "+";
begin
   Put( Plus(1,2));
end Operators;

Thanks,
Joe



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-10-16  8:14 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-14 15:35 Using a string as a binary operator Joe
2008-10-14 17:05 ` Dmitry A. Kazakov
2008-10-14 18:51 ` Jeffrey R. Carter
2008-10-15 15:22   ` Adam Beneschan
2008-10-15 17:23     ` Jeffrey R. Carter
2008-10-15 19:32     ` sjw
2008-10-16  8:14     ` Dmitry A. Kazakov
2008-10-14 22:01 ` george.priv
2008-10-15  3:51 ` Gene
2008-10-15  5:45 ` anon
2008-10-15 12:18   ` Joe
2008-10-15 13:43     ` John McCormick

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox