diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/metamethods.md | 14 | ||||
| -rw-r--r-- | docs/strings.md | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/docs/metamethods.md b/docs/metamethods.md index c3231883..1a1eb0e2 100644 --- a/docs/metamethods.md +++ b/docs/metamethods.md @@ -3,7 +3,7 @@ This language relies on a small set of "metamethods" which define special behavior that is required for all types: -- `as_str(obj:&(optional)T, colorize=no)->Str`: a method to convert the type to a +- `as_text(obj:&(optional)T, colorize=no)->Text`: a method to convert the type to a string. If `colorize` is `yes`, then the method should include ANSI escape codes for syntax highlighting. If the `obj` pointer is `NULL`, a string representation of the type will be returned instead. @@ -32,12 +32,12 @@ _every_ type had its own set of metamethods. To reduce the amount of generated code, we use generic metamethods, which are general-purpose functions that take an automatically compiled format string and variable number of arguments that describe how to run a metamethod for that type. As a simple example, if `foo` -is an array of type `Foo`, which has a defined `as_str()` method, then -rather than define a separate `Foo_Array_as_str()` function that would be -99% identical to a `Baz_Array_as_str()` function, we instead insert a call -to `as_str(&foo, colorize, "[_]", Foo__as_str)` to convert a `[Foo]` -array to a string, and you call `as_str(&baz, colorize, "[_]", -Baz__as_str)` to convert a `[Baz]` array to a string. The generic metamethod +is an array of type `Foo`, which has a defined `as_text()` method, then +rather than define a separate `Foo_Array_as_text()` function that would be +99% identical to a `Baz_Array_as_text()` function, we instead insert a call +to `as_text(&foo, colorize, "[_]", Foo__as_text)` to convert a `[Foo]` +array to a string, and you call `as_text(&baz, colorize, "[_]", +Baz__as_text)` to convert a `[Baz]` array to a string. The generic metamethod handles all the reusable logic like "an array's string form starts with a '[', then iterates over the items, getting the item's string form (whatever that is) and putting commas between them". diff --git a/docs/strings.md b/docs/strings.md index a981be2a..d2e886bf 100644 --- a/docs/strings.md +++ b/docs/strings.md @@ -276,7 +276,7 @@ To compare normalized forms of strings, use: ### Patterns - `string.has($/pattern/, at=Anywhere:enum(Anywhere, Start, End))` Check whether a pattern can be found -- `string.next($/pattern/)` Returns an `enum(NotFound, Found(match:Str, rest:Str))` +- `string.next($/pattern/)` Returns an `enum(NotFound, Found(match:Text, rest:Text))` - `string.matches($/pattern/)` Returns a list of matching strings - `string.replace($/pattern/, "replacement")` Returns a copy of the string with replacements - `string.without($/pattern/, at=Anywhere:enum(Anywhere, Start, End))` |
