Hubbry Logo
search
logo

Scope resolution operator

logo
Community Hub0 Subscribers
Write something...
Be the first to start a discussion here.
Be the first to start a discussion here.
See all
Scope resolution operator

In computer programming, scope is an enclosing context where values and expressions are associated. The scope resolution operator helps to identify and specify the context to which an identifier refers, particularly by specifying a namespace or class. The specific uses vary across different programming languages with the notions of scoping. In many languages, the scope resolution operator is written ::.

In some languages, notably those influenced by Modula-3 (including Python and Go), modules are objects, and scope resolution within modules is a special case of usual object member access, so the usual method operator . is used for scope resolution. Other languages, notably C++ and Ruby, feature both scope resolution and method access, which interact in various ways; see examples below.

In PHP, the scope resolution operator is also called Paamayim Nekudotayim (Hebrew: פעמיים נקודותיים, pronounced [paʔaˈmajim nekudoˈtajim], the second word a colloquial corruption[better source needed] of נקודתיים, pronounced [nekudaˈtajim]), which means “double colon” in Hebrew.

The name "Paamayim Nekudotayim" was introduced in the Israeli-developed Zend Engine 0.5 used in PHP 3. Initially the error message simply used the internal token name for the ::, T_PAAMAYIM_NEKUDOTAYIM causing confusion for non-Hebrew speakers. This was clarified in PHP 5.4 as below:

As of PHP 8, the Hebrew name has been removed from the error message:

In Ruby, scope resolution can be specified using the module keyword.

Scope is also affected by sigils which preface variable names:

Python does not have a dedicated scope resolution operator. Name lookup follows the LEGB rule (Local, Enclosed, Global, Built-in). Access to attributes of modules, classes, and objects is performed using the dot (.) operator.

See all
User Avatar
No comments yet.