Style guide
CL++ is not C++. Write the forms this compiler emits. The editor pack (clpp install) highlights them.
- Headers:
.clh. Modules:.clp/ untagged.clpp. Scripts:.server.clpp/.client.clpp. - One service type per pair:
LeaderstatsServer.clhnext toLeaderstatsServer.server.clpp. #include <clpp/roblox.clh>for engine names.#include <clpp/libs/janitor.clh>when you use~>.
- Instances are class names:
Player player,Players players,BasePart part. - There is no address-of and no
->. Properties and instance methods use.. - Prefer
for (Player player in players.GetPlayers())over the C++:range-for.
- Define methods with
Class::Method. Call them with.(hello.Greet(player)). - Inside a method,
@thisis the object (self).@janitorisself.janitor. Bare fields still becomeself.field. - Do not put
@thison the parameter list.::already injects the receiver. thiswithout@is the same alias. Prefer@this.
void CombatServer::BindPart(BasePart part) { @janitor.Add(part, "Destroy"); other.Register(@this);}Operators
Section titled “Operators”| Write | Do not write |
|---|---|
"hi " .: name | "hi " .. name or "hi " + name |
players.PlayerAdded~>Connect(fn) | ::Connect unless you will Disconnect yourself |
func (Player player) { } | []() {} or func [](…) |
name.Fire(...) | name::Fire |
player.Kick() | player->Kick() |
Scripts
Section titled “Scripts”- Entry is
void init(). There is noint main(). - Construct one service object in
init()and close over it from callbacks. post/warn/report— notprint/error/tostring. Useto_string/to_number/to_bool.
Editor
Section titled “Editor”Reload the window after clpp setup / clpp install. @ is the receiver sigil; @this and @field color differently.