1

Are there any programming languages with module import routines that have the following behavior:

import lib as x
import lib as y
x == y # False

This is in Python syntax; although Python would return True from the comparison. I don't know of a language that has this kind of behavior. Is there case where this is explicitly a "language feature" and not a workaround?

Community
  • 1
  • 1
devoid
  • 1,009
  • 10
  • 16

1 Answers1

4

CommonJS modules and NodeJS modules offer such a case, where every import/require returns an object which is assigned to a variable and then the features are accessed via that reference.

Newspeak modules(PDF) offer a more research-oriented take where the modules are instantiated with parameters and then assigned to a variable/local slot which offers even more flexibility but obviously Newspeak isn't commonly-used.