# Scopes and Constants

BoxLang has a number of implicit scopes, some which are available only in certain runtimes:

1. `Variables`: This is the default scope for all variables that are not explicitly scoped. Variables in this scope are available only within the page or component where they are created or, in the case of included templates, within the child templates.
2. `Arguments`: This scope contains all the arguments passed to a function. They are available only within the function where they are defined.
3. `This`: This scope is used within a component to refer to the component itself. It can be used to access the public properties and methods of the component.
4. `Local`: This scope is used within a function to define variables that are only available within that function. It's similar to the `Variables` scope but is limited to the function where it's defined.
5. `Thread`: This scope is used within a `thread` component to define variables that are only available within that thread.
6. `Request`: This scope is available throughout the entire request, regardless of page boundaries. It's useful for storing data that needs to be accessed across multiple pages during a single request.
7. `Session`: This scope is available throughout the user's session. It's useful for storing data that needs to be accessed across multiple requests by the same user.
8. `Application`: This scope is available to all pages within the application. It's useful for storing data that needs to be accessed by all users of the application.
9. `Server`: This scope is available to all pages on the server, regardless of the application. It's rarely used, but can be useful for storing data that needs to be accessed by all applications on the server.
10. `Form` (Web runtime only): This scope contains all the form fields submitted in a POST request.
11. `URL` (Web runtime only): This scope contains all the parameters passed in the URL.
12. `CGI` (Web runtime only): This scope contains information about the request, such as the IP address of the client, the user agent string, and so on.
13. `bxThread` : This scope is available anywhere in a request and contains a key for every thread which has been run in that request. The value for the key contains the metadata for that thread as well as any variables set from inside that thread into the thread's thread "scope"

Remember that scoping your variables explicitly is a good practice as it makes your code easier to read and understand, as well as preventing the need for "scope walking" ( attempting to find a variable reference in nearby scopes ). Explicit scoping of your variables provides significant increases in performance.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/lexical-elements/scopes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
