aboutsummaryrefslogtreecommitdiff
path: root/docs/metamethods.md
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-03-03 18:15:45 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-03-03 18:15:45 -0500
commit8fab88c56f95c03ffcb4be178f5dbb21b239d95e (patch)
tree3c2e721b8ea55d43b94fa9f315659580652573c5 /docs/metamethods.md
parent07f0a18136a7883d1f3edd3e08253bd3020294a8 (diff)
Rename Str -> Text
Diffstat (limited to 'docs/metamethods.md')
-rw-r--r--docs/metamethods.md14
1 files changed, 7 insertions, 7 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".