0

When a compiler compiles a procedure, I understand that there's a 'Linkage convention' for ensuring that the caller and callee's environments are sorted out fine in this situation.

How can a compiler know if different linkages are 'safe'. I would assume this means that as long as the same input from the caller results in the same output for the caller then these linkages are 'equivalent' and therefore 'safe' as they don't mess up the caller in any way. What's an example from a programming language though? I would say maybe when different libraries are compiled using different versions of a language and you call them in a main class, it all works fine.

What could a compiler change about the calling sequence and linkage convention to make these different 'variant' linkages that are considered 'safe'?

Awoken
  • 79
  • 6

1 Answers1

0

The compiler can know that using a variant linkage is safe if it always knows the context in which a procedure will be called. For example, if a procedure is private to a class and can only be called from that class and no where else, you can change the linkage convention to something specific to the state of that class. You wouldn't be able to do this with a library.

Awoken
  • 79
  • 6