Type Prototypes
Nubo values can have functions attached to them through type prototypes.
A prototype is like a method table for a value. It lets you call functions directly on values:
let s = "hello"
println(s.length())println(s.toUpperCase())This means many values in Nubo are not just raw data. They can expose useful behavior.
Prototype Pages
Section titled “Prototype Pages”| Page | Description |
|---|---|
| Strings | String helpers like length, includes, split, trim, and case conversion. |
| Lists | List helpers like push, pop, map, filter, slice, and indexed access. |
| Dictionaries | Dictionary helpers like keys, values, remove, and indexed access. |
| Integers | Integer helpers like increment and decrement. |
| HTML Elements | Attribute and children helpers for html values. |
| Functions | Function metadata and initialized calls. |
| Structs | Struct fields, methods, private fields, and special hooks. |
| Internal Hooks | Internal names like __get__, __set__, __args__, and __returns__. |
Current Literal Limitation
Section titled “Current Literal Limitation”Prototype calls currently work reliably on values stored in variables.
let s = "string"
println(s.length())Calling prototype methods directly on literals is currently limited by AST/parser behavior.
// Currently may not work:println("string".length())Prefer assigning the literal to a variable first.
let text = "string"
println(text.length())Best Practice
Section titled “Best Practice”Use prototype methods when they make code easier to read.
let text = "a,b,c"let parts = text.split(",")
println(parts)Avoid direct literal method calls until AST support is complete.
// Avoid for now:println("hello".length())