DevLearningTools

MODULE 6 · LESSON 01

Built-in Functions

Touring ColdFusion's built-in function library — categories, nesting functions, and the modern first-class-function feature that lets you pass a built-in function around like any other value.

New lessons are added one at a time as the course gets built out — a graded quiz for each lesson is still on the way.

Every function used so far in this course — arrayLen, structKeyExists, serializeJSON, dateFormat — is a built-in function. ColdFusion ships with hundreds of them, covering almost everything a typical application needs without reaching for a third-party library.

This lesson is a map of that library, plus a genuinely modern CFML feature: built-in functions can be treated as first-class values, passed around and used as callbacks exactly like the user-defined functions in the next lesson.

Learning Objectives

After completing this lesson, you'll be able to:

  • Call and nest built-in functions inside expressions.
  • Name the major categories of ColdFusion's built-in function library.
  • Pass a built-in function as a value to another function, using first-class function syntax.
  • Know when NOT to reach for dynamic/reflective function calls.

Calling and Nesting Functions

A function call is just an expression, so function calls can be nested directly inside each other — the innermost one runs first.

CFScript
Simulated output — illustrative only, not a live ColdFusion/Lucee server.
Tag Syntax
Simulated output — illustrative only, not a live ColdFusion/Lucee server.

Categories of Built-in Functions

Most of these categories already have their own dedicated lessons or are coming up later in the course — this is just the map.

CategoryExamples
Array / List / StructarrayLen, listAppend, structKeyExists
StringuCase, trim, reReplace
Date & Timenow, dateFormat, dateAdd
Mathround, min, randRange
QueryqueryNew, valueList
JSON / XMLserializeJSON, xmlParse
Securityhash, encrypt, generateSecretKey
File / DirectoryfileRead, directoryList
ImageimageResize, imageNew

Built-in Functions as First-Class Values

In modern CFML, a built-in function can be passed by name — without calling it — to another function, which can then call it later. This is the same pattern arrayMap and arrayFilter use with your own closures, except here the callback is a built-in function instead of one you wrote.

CFScript
Simulated output — illustrative only, not a live ColdFusion/Lucee server.
Tag Syntax
Simulated output — illustrative only, not a live ColdFusion/Lucee server.
NOTE

Notice lCase is passed without parentheses — lCase, not lCase(). Adding parentheses would call it immediately instead of handing it over as a value.

What Not to Do: Calling a Function by a Dynamic Name

Sometimes people want to call a built-in function whose name is only known at runtime, stored in a string. It's technically possible (evaluate() on Adobe ColdFusion, getBuiltinFunction() on Lucee) but it's fragile: named arguments don't work through it, and a handful of functions (writeDump, location, throw) can't be reached this way at all. If you need dynamic dispatch, write your own small mapping — a struct of names to functions — instead of relying on reflection tricks.

Common Beginner Mistakes

Calling lCase() instead of passing lCase when it's meant to be a callback

lCase("One") runs immediately and passes the string "one" as the argument. lCase, with no parentheses, passes the function itself — that's what a callback parameter expects.

Assuming every function is available on every engine

A number of functions are Adobe ColdFusion-only or Lucee-only. Check the function's documentation page before relying on it if the code needs to run on both engines.

Best Practices

  • Reach for a built-in function before writing your own — check whether ColdFusion already has one for what you need.
  • Use first-class function passing for simple transformations (lCase, uCase, trim) instead of writing a one-line wrapper closure just to satisfy a callback signature.
  • Avoid evaluate() / getBuiltinFunction() for dynamic dispatch — prefer an explicit mapping struct.

Interview Questions

What does it mean for a built-in function to be "first-class" in ColdFusion?

It means the function itself can be assigned to a variable or passed as an argument without being called — the same way a user-defined closure can be passed to arrayMap or arrayFilter.

What's the risk of calling a built-in function by name using evaluate()?

Named arguments don't work through it, a few functions can't be reached that way at all, and it's generally fragile — an explicit mapping struct is safer.

Summary

In this lesson, you toured the major categories of ColdFusion's built-in function library and learned that built-in functions can be passed around as first-class values, the same as user-defined closures.

What's Next?

The next lesson covers writing your own functions — user-defined functions, in both CFScript and tag syntax.