Scopes and Constants
BoxLang has a number of implicit scopes, some which are available only in certain runtimes:
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.Arguments
: This scope contains all the arguments passed to a function. They are available only within the function where they are defined.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.Local
: This scope is used within a function to define variables that are only available within that function. It's similar to theVariables
scope but is limited to the function where it's defined.Thread
: This scope is used within athread
component to define variables that are only available within that thread.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.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.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.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.Form
(Web runtime only): This scope contains all the form fields submitted in a POST request.URL
(Web runtime only): This scope contains all the parameters passed in the URL.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.
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.
Last updated