Re: 2 Pass Binder

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

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

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

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

EU>   object   operand
EU>   sequence routine_name
EU>   integer  choice

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

EU>   choice = get_number (0)

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

EU>   operand = get_object (0)

EU>   routine_name = commands[choice]

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

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


EU>Rod

With this, though, a smart binder could do the following:
1. see that commands is a constant
2. see that the argument to routine_id is an element of commands
3. know to leave in any routines named in commands

Since many programs do have routines that aren't used, it would leave
these out even though it uses routine_ids. For example, if you included
get.e and used get(0) instead of get_object(0), the binder would know ro
remove everything that isn't used in the program or listed in commands.
So the binder could get rid of M_WAIT_KEY, wait_key(), prompt_number(),
prompt_string(), get_bytes() (and maybe some more with more detailed
analisys).

Jeffrey Fielding
JJProg at cyberbury.net
http://members.tripod.com/~JJProg/

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

Search



Quick Links

User menu

Not signed in.

Misc Menu