comp.lang.ada
 help / color / mirror / Atom feed
From: Joe <joesmoe10@gmail.com>
Subject: Using a string as a binary operator
Date: Tue, 14 Oct 2008 08:35:23 -0700 (PDT)
Date: 2008-10-14T08:35:23-07:00	[thread overview]
Message-ID: <8cbb04c3-e789-4b67-897a-fd6f83486bbc@x16g2000prn.googlegroups.com> (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



             reply	other threads:[~2008-10-14 15:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-14 15:35 Joe [this message]
2008-10-14 17:05 ` Using a string as a binary operator 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
replies disabled

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