Cluaupp — anonymous callbacks
This note is for Cluaupp: templates, snippets, generated .clpp, and tests that write CL++ source. The compile JSON contract (clpp api compile) did not change. The language did.
CL++ anonymous callbacks are now func (params) { }. The C++ capture list is gone.
Write this
Section titled “Write this”players.PlayerAdded~>Connect(func (Player playerEntered) { post("hello, " .: playerEntered.Name);});
pcall(func () { return 1;});
func onCoinsChanged = func (int newValue) { post(newValue);};Zero parameters still need the keyword and empty parens: func () { }.
Do not emit this
Section titled “Do not emit this”These do not compile:
func [](Player player) { }[]() { }func []() { }[] is only indexing (names[0], stats["Coins"], folder[childName]). It is not a lambda.
Emit (unchanged shape)
Section titled “Emit (unchanged shape)”Cluaupp still receives ordinary Luau from clpp api compile. A janitor Connect stays a janitor Connect:
players.PlayerAdded~>Connect(func (Player playerEntered) { post(playerEntered.Name);});janitor:Add(players.PlayerAdded:Connect(function(playerEntered: Player) print(playerEntered.Name)end), "Disconnect")Manual connect (no Janitor) is ::Connect with the same func ( body.
Grammar Cluaupp can rely on
Section titled “Grammar Cluaupp can rely on”The compiler requires:
func ( [params] ) { statements }- Keyword
func(also the type). (…)— parameter list may be empty.{…}— body. No->.
Named functions are unchanged: void Greet(Player player) { }.
Operators in generated source
Section titled “Operators in generated source”When Cluaupp prints accessors next to a callback, use the current table:
| CL++ | Meaning |
|---|---|
. | Property and instance method (player.Name, player.Kick(), workspace.FindFirstChild("x")) |
: | Type on a name, or a protected (pcall) call (age: int, player:Kick()) |
:: | Static / class method definition / manual Connect |
~> | Connect / Once with Janitor |
[] | Index only |
Diagnostics
Section titled “Diagnostics”clpp api compile returns ok: false plus diagnostics[] when a file still has func [] / [](). The editor pack lints the same line:
use func (params) { } — CL++ does not use captures []
After shipping a new clpp, Cluaupp users need a language-pack refresh so Error Lens / CL++ Lens shows that message: clpp setup / clpp install, or copy editors/vscode into the editor extensions folder, then reload.
What to update in Cluaupp
Section titled “What to update in Cluaupp”- Scaffold /
inittemplates — everyConnect,Once,OnChange,pcall, Vide/Fusion callback. - Snippet generators — stop concatenating
func [](or[](. - Golden
.clppfixtures — rewrite tofunc (Type name) { }. - Docs and UI copy that showed
[]()as “CL++ lambda”. - Tests that asserted
func []still compiled — they should now expect failure.
The CompileRequest / CompileArtifact types in support/cluaupp.d.ts stay the same shape. Full CLI upgrade (0.7.0): Cluaupp 0.7.0 and Update Cluaupp.
Language pages
Section titled “Language pages”func (…) · func · Connect · operators · JSON contract