Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/namespaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,18 @@ sub Vertibrates_Reptiles_Hiss()
end sub
```
</details>


## Caveats
### ObserveField and ObserveFieldScoped
It's incredibly difficult for brighterscript to know when it's safe to transpile strings that happen to look like namespace names. As such, the `ObserveField` and `ObserveFieldScoped` functions in BrighterScript do not automatically transpile string-based function names into their BrightScript-compatible underscore format.

This means that if you pass a namespaced identifier as a string (i.e `Vertibrates.Birds.Quack`) it will not be converted to `Vertibrates_Birds_Quack` during transpilation. Developers need to ensure they manually provide the transpiled function name when using these functions to avoid runtime errors (i.e. `Vertibrates_Birds_Quack`).

```brighterscript
'this does not work
m.top.observeField("someField", "Vertibrates.Birds.Quack")

'you need to do this instead
m.top.observeField("someField", "Vertibrates_Birds_Quack")
```