Normalize daw_register guards across all Lua files #49

Closed
opened 2026-08-14 14:49:37 +02:00 by michael · 1 comment
Owner

Problem

While migrating daw-lua-common to daw_i18n/v1, review repeatedly
encounters older self-registration guards at the end of Lua files:

if type(_G.daw_register) == "function" then
  _G.daw_register(_NAME, M)
end

The accepted DAW runtime rule is the simpler truthy guard:

if _G.daw_register then
  _G.daw_register(_NAME, M)
end

This has already been identified for individual files, but checking it
opportunistically during unrelated migrations creates repeated review
noise and risks mixing unrelated changes into other issues.

Goal

Review all Lua source files in daw-lua-common once and align every
self-registration guard with the accepted DAW pattern.

This is a repository-wide cleanup pass, separate from the ongoing
daw_i18n/v1 migration.

Scope

For every Lua source file in the repository:

  • inspect the file ending / registration block,
  • identify whether _G.daw_register is used,
  • replace the explicit type check with the accepted truthy guard where
    applicable,
  • preserve _NAME, registration arguments, module return values, and
    all unrelated behavior,
  • do not introduce registration into files that currently do not
    register themselves,
  • do not perform unrelated cleanup while touching the files.

Accepted form:

if _G.daw_register then
  _G.daw_register(_NAME, M)
end

Verification

The pass should also confirm that no alternative registration guard
remains, such as:

if type(_G.daw_register) == "function" then

or other equivalent variants.

Acceptance criteria

  • Every Lua source file in daw-lua-common has been inspected.
  • Every existing self-registration block uses the accepted truthy
    _G.daw_register guard.
  • No explicit type(_G.daw_register) == "function" guard remains.
  • No new self-registration behavior is introduced in files that did
    not previously register themselves.
  • No unrelated code changes are included in the cleanup.
  • fragjan code . passes.
  • make test passes under Lua 5.1 and Lua 5.4.
  • DAW/daw-lua-common#45
  • DAW/daw-lua-common#48
  • DAW/daw-docs#18
## Problem While migrating `daw-lua-common` to `daw_i18n/v1`, review repeatedly encounters older self-registration guards at the end of Lua files: ```lua if type(_G.daw_register) == "function" then _G.daw_register(_NAME, M) end ``` The accepted DAW runtime rule is the simpler truthy guard: ```lua if _G.daw_register then _G.daw_register(_NAME, M) end ``` This has already been identified for individual files, but checking it opportunistically during unrelated migrations creates repeated review noise and risks mixing unrelated changes into other issues. ## Goal Review all Lua source files in `daw-lua-common` once and align every self-registration guard with the accepted DAW pattern. This is a repository-wide cleanup pass, separate from the ongoing `daw_i18n/v1` migration. ## Scope For every Lua source file in the repository: - inspect the file ending / registration block, - identify whether `_G.daw_register` is used, - replace the explicit type check with the accepted truthy guard where applicable, - preserve `_NAME`, registration arguments, module return values, and all unrelated behavior, - do not introduce registration into files that currently do not register themselves, - do not perform unrelated cleanup while touching the files. Accepted form: ```lua if _G.daw_register then _G.daw_register(_NAME, M) end ``` ## Verification The pass should also confirm that no alternative registration guard remains, such as: ```lua if type(_G.daw_register) == "function" then ``` or other equivalent variants. ## Acceptance criteria - [ ] Every Lua source file in `daw-lua-common` has been inspected. - [ ] Every existing self-registration block uses the accepted truthy `_G.daw_register` guard. - [ ] No explicit `type(_G.daw_register) == "function"` guard remains. - [ ] No new self-registration behavior is introduced in files that did not previously register themselves. - [ ] No unrelated code changes are included in the cleanup. - [ ] `fragjan code .` passes. - [ ] `make test` passes under Lua 5.1 and Lua 5.4. ## Related - `DAW/daw-lua-common#45` - `DAW/daw-lua-common#48` - `DAW/daw-docs#18`
Author
Owner

Done

Verified on main:

  • 21 Lua source files register themselves (same count as at v2.1.0),
    and all 21 use the truthy 'if _G.daw_register then' guard.
  • No 'type(_G.daw_register)' variant remains (grep, excluding test/
    and lib/).
  • The 7 files without any registration (fs/dir, fs/file, fs/handle,
    fs/query, fs/temp, yaml/dump, yaml/parse) did not register before
    either, so no new self-registration was introduced.

The base64.lua outlier was fixed as described in
DAW/daw-lua-common#44.

## Done Verified on main: - 21 Lua source files register themselves (same count as at v2.1.0), and all 21 use the truthy 'if _G.daw_register then' guard. - No 'type(_G.daw_register)' variant remains (grep, excluding test/ and lib/). - The 7 files without any registration (fs/dir, fs/file, fs/handle, fs/query, fs/temp, yaml/dump, yaml/parse) did not register before either, so no new self-registration was introduced. The base64.lua outlier was fixed as described in DAW/daw-lua-common#44.
michael 2026-09-20 21:36:53 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/daw-lua-common#49
No description provided.