boxlang-functional-programming
BoxLang Functional Programming
Overview
BoxLang treats functions as first-class values. Functions can be stored in variables, passed as arguments, returned from other functions, and used in functional pipelines. BoxLang supports closures, lambdas, and arrow functions with a clean, expressive syntax.
Closures vs Lambdas — Critical Distinction
This distinction matters for correctness:
| Syntax | Name | Scope Capture | Use When |
|---|---|---|---|
(args) => expr |
Closure | ✅ Yes — captures surrounding scope | Accesses outer variables or calls external functions/BIFs |
(args) -> expr |
Lambda | ❌ No — only uses its own args | Purely deterministic; only works with passed arguments |
function(...) {} |
UDF/Closure | ✅ Yes — when assigned to a variable/returned | Named or complex multi-line function bodies |
More from ortus-boxlang/skills
boxlang-classes-and-oop
Use this skill when writing BoxLang classes, components, interfaces, inheritance hierarchies, annotations, properties, constructors, or applying object-oriented design patterns in BoxLang.
12boxlang-best-practices
Use this skill when writing, reviewing, or improving BoxLang code to ensure it follows community best practices for naming, structure, scoping, error handling, performance, and maintainability.
12boxlang-code-reviewer
Use this skill when reviewing BoxLang code for quality, correctness, security vulnerabilities, performance issues, style violations, or when providing structured code review feedback following BoxLang best practices and security guidelines.
12boxlang-configuration
Use this skill when configuring BoxLang runtime settings via boxlang.json, setting environment variables for config overrides, configuring datasources, caches, executors, modules, logging, security, or schedulers — or when helping someone understand the BoxLang configuration system.
11boxlang-web-development
Use this skill when building BoxLang web applications: Application.bx lifecycle, request/response handling, sessions, forms, REST APIs, HTTP clients, routing, CSRF protection, Server-Sent Events, or configuring CommandBox/MiniServer.
11boxlang-language-fundamentals
Use this skill when writing or reviewing BoxLang code covering syntax, file types, variables, scopes, operators, control flow, exception handling, type system, and modern language features like destructuring and spread syntax.
11