Search code examples
pythonlanguage-featuresencapsulation

Python descriptor protocol analog in other languages?


Is there something like the Python descriptor protocol implemented in other languages? It seems like a nice way to increase modularity/encapsulation without bloating your containing class' implementation, but I've never heard of a similar thing in any other languages. Is it likely absent from other languages because of the lookup overhead?


Solution

  • I've not heard of a direct equivalent either. You could probably achieve the same effect with macros, especially in a language like Lisp which has extremely powerful macros.

    I wouldn't be at all surprised if other languages start to incorporate something similar because it is so powerful.