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 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. class A { public: static int i; // scope of i is A }; namespace B { int c = 2; } // namespace B int A::i = 4; // scope operator refers to the integer i declared in the class A int x = B::c; // scope operator refers to the integer c declared in the namespace B $ php -r :: Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM) As of PHP 8, the Hebrew name has been removed from the error message: $ php -r :: Parse error: syntax error, unexpected token "::", expecting end of file in Command line code on line 1 module Example Version = 1.0 class "Hello world" Example.hello "hacker" # => "Hello hacker" Example::Version # => 1.0 Example.Version # NoMethodError This illustrates the difference between the message (.) operator and the scope operator in Ruby (::) We can use both ::hello and .hello, because hello is a part of Example's scope and because Example responds to the message hello. We can't do the same with ::Version and .Version, because Version is within the scope of Example, but Example can't respond to the message Version, since there is no method to respond with. Scope is also affected by sigils which preface variable names: " $ " - global variable " @ " - instance variable of self " @@ " - class variable No sigil, lowercase or underscore - local variable or method No sigil, uppercase - constant 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. import math x = 5 # global variable def outer(): x = 10 # enclosing scope def inner(): print(x) # resolves to the enclosing scope inner() outer() print(math.pi) # attribute access using the dot operator
References
- WTF Is T_paamayim_nekudotayim (2013) | Hacker News · retrieved 2025-05-16 · rev 1343574744
Cite this reference
MLA "WTF Is T_paamayim_nekudotayim (2013) | Hacker News." 2025-05-16. https://web.archive.org/web/20250130082624/https://news.ycombinator.com/item?id=33829645#33851908. Accessed 24 November 2026.
Chicago "WTF Is T_paamayim_nekudotayim (2013) | Hacker News." 2025-05-16. https://web.archive.org/web/20250130082624/https://news.ycombinator.com/item?id=33829645#33851908.
APA encyclopegia.org. (2025). WTF Is T_paamayim_nekudotayim (2013) | Hacker News. Retrieved November 24, 2026, from https://web.archive.org/web/20250130082624/https://news.ycombinator.com/item?id=33829645#33851908
- WTF Is T_paamayim_nekudotayim (2013) | Hacker News · retrieved 2025-05-16 · rev 1343574744
Cite this reference
MLA "WTF Is T_paamayim_nekudotayim (2013) | Hacker News." 2025-05-16. https://news.ycombinator.com/item?id=33829645. Accessed 24 November 2026.
Chicago "WTF Is T_paamayim_nekudotayim (2013) | Hacker News." 2025-05-16. https://news.ycombinator.com/item?id=33829645.
APA encyclopegia.org. (2025). WTF Is T_paamayim_nekudotayim (2013) | Hacker News. Retrieved November 24, 2026, from https://news.ycombinator.com/item?id=33829645
- [PHP] T_PAAMAYIM_NEKUDOTAYIM, a tale of nerd gridlock · retrieved 2025-05-16 · rev 1343574744
Cite this reference
MLA "[PHP] T_PAAMAYIM_NEKUDOTAYIM, a tale of nerd gridlock." smog_alado (2021-04-24). 2025-05-16. https://www.reddit.com/r/HobbyDrama/comments/mxrk6r/php_t_paamayim_nekudotayim_a_tale_of_nerd_gridlock/. Accessed 24 November 2026.
Chicago "[PHP] T_PAAMAYIM_NEKUDOTAYIM, a tale of nerd gridlock." smog_alado (2021-04-24). 2025-05-16. https://www.reddit.com/r/HobbyDrama/comments/mxrk6r/php_t_paamayim_nekudotayim_a_tale_of_nerd_gridlock/.
APA smog_alado (2021-04-24). (2025). [PHP] T_PAAMAYIM_NEKUDOTAYIM, a tale of nerd gridlock. Retrieved November 24, 2026, from https://www.reddit.com/r/HobbyDrama/comments/mxrk6r/php_t_paamayim_nekudotayim_a_tale_of_nerd_gridlock/
- Scope Resolution Operator · retrieved 2007-08-08 · rev 1343574744
Cite this reference
MLA "Scope Resolution Operator." 2007-08-08. http://php.net/manual/language.oop5.paamayim-nekudotayim.php. Accessed 24 November 2026.
Chicago "Scope Resolution Operator." 2007-08-08. http://php.net/manual/language.oop5.paamayim-nekudotayim.php.
APA encyclopegia.org. (2007). Scope Resolution Operator. Retrieved November 24, 2026, from http://php.net/manual/language.oop5.paamayim-nekudotayim.php
- PHP: rfc:rename-double-colon-token · retrieved 2025-05-16 · rev 1343574744
Cite this reference
MLA "PHP: rfc:rename-double-colon-token." 2025-05-16. https://wiki.php.net/rfc/rename-double-colon-token. Accessed 24 November 2026.
Chicago "PHP: rfc:rename-double-colon-token." 2025-05-16. https://wiki.php.net/rfc/rename-double-colon-token.
APA encyclopegia.org. (2025). PHP: rfc:rename-double-colon-token. Retrieved November 24, 2026, from https://wiki.php.net/rfc/rename-double-colon-token
- 2T8qQ - created on 3v4l.org · retrieved 2025-05-16 · rev 1343574744
Cite this reference
MLA "2T8qQ - created on 3v4l.org." "2T8qQ - created on 3v4l. 2025-05-16. https://3v4l.org/2T8qQ. Accessed 24 November 2026.
Chicago "2T8qQ - created on 3v4l.org." "2T8qQ - created on 3v4l. 2025-05-16. https://3v4l.org/2T8qQ.
APA "2T8qQ - created on 3v4l. (2025). 2T8qQ - created on 3v4l.org. Retrieved November 24, 2026, from https://3v4l.org/2T8qQ
- 4. Execution model · retrieved 2026-03-14 · rev 1343574744
Cite this reference
MLA "4. Execution model." "4. 2026-03-14. https://docs.python.org/3/reference/executionmodel.html. Accessed 24 November 2026.
Chicago "4. Execution model." "4. 2026-03-14. https://docs.python.org/3/reference/executionmodel.html.
APA "4. (2026). 4. Execution model. Retrieved November 24, 2026, from https://docs.python.org/3/reference/executionmodel.html
Cite this article
MLA
"Scope resolution operator." encyclopegia.org, 2026, https://encyclopegia.org/wiki/scope-resolution-operator. Accessed 24 November 2026.
Chicago
"Scope resolution operator." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/scope-resolution-operator.
APA
encyclopegia.org. (2026). Scope resolution operator. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/scope-resolution-operator
Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON