I have toyed with the idea of object aliases several times in the past. Your example illustrates using object aliases within an entity but it might also be interesting to support global object aliases. Reusing your example, you could define a global object alias, e.g. in your code loader file:
This alias would allow all references to the object "tree", in all loaded code, to be translated to references to the object "bintree". One advantage would be that we could write an application using e.g. generic names such as "tree" or "queue" and easily experiment with different implementations of the aliased objects.
Note, however, that you could simplify your example by using instead a uses/2 directive. In this solution, you only need to change the first argument to get the same functionality of object aliases.
I have just implemented a first version of the alias/2 entity directive you suggested. This first version doesn't support global object aliases (which require a different compilation and implementation solution). In addition, it doesn't cover the case where a message sending call, constructed at runtime, targets the object alias. Doing so would require retaining the alias information in the compiled code (as with the alias/3 predicate directive). I need to think a bit more on the consequences of adding the alias/2 before committing a final implementation but I can give you an updated Logtalk compiler if you want to try this first version.
Thanks for your suggestion. I will post updates on this thread. Cheers,