Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Expand on the first argument to subst. #753

Merged
merged 1 commit into from
Jul 15, 2023
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
11 changes: 9 additions & 2 deletions docs/Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,18 @@ program state.
in all lowercase.
* `subst(old, new, val)`, a function of three arguments which returns the
input `val` with all substrings or patterns `old` replaced by `new`. When
given a string for `old`, it is a direct proxy of the Go
given a *string* for `old`, it is a direct proxy of the Go
[strings.ReplaceAll](https://golang.org/pkg/strings/#ReplaceAll) function.
When given a regular expression pattern for `old`, it uses

`subst("old", "new", $val)`

When given a *regular expression pattern* for `old`, it uses
[regexp.ReplaceAllLiteralString](https://golang.org/pkg/regexp/#Regexp.ReplaceAllLiteralString).

`subst(/old/, "new", $val)`

Note the different quote characters in the first argument.

There are type coercion functions, useful for overriding the type inference made
by the compiler if it chooses badly. (If the choice is egregious, please file a
bug!)
Expand Down
Loading