Re: 2 Pass Binder

new topic     » goto parent     » topic index » view thread      » older message » newer message

Bernie Ryan wrote:

>   To solve the routine id problem just scan from the bottom up.

Bernie,

Let's assume I have the following (pseudo-code) program:

   function sqr (object x)
      return x * x
   end function

   function sqrt (object x)
      return sqrt (x)
   end function

   constant commands = {"sqr", "sqrt"}

   object   operand
   sequence routine_name
   integer  choice

   puts (1, "You have the following options:\n\n")
   for i = 1 to length (commands) do
      puts (1, ('0' + i) & ") " & commands[i] & "\n") -- "i) name\n"
   end for
   puts (1, "\nEnter number of choice: ")

   choice = get_number (0)

   puts (1, "\n\nEnter object to apply to: ")

   operand = get_object (0)

   routine_name = commands[choice]

   ? call_func (routine_id (routine_name), {operand})

Now, how could I expect the binder to know to leave in the two
functions above? It HAS to leave both in the code, even though it
can't tell if either of them will ever be used.

This is just one example, true, but the idea can be applied in a
wide variety of ways. A simple remove-what-isn't-referenced works
fine for constants, variables, and maybe even types. But it won't
work for routines whenever routine_id is used with variables.
Either some part of the code has to be forced to change, or some
other approach has to be taken.


Rod

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu