aboutsummaryrefslogtreecommitdiff
path: root/doc/language/cpsc-language-overview.7.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/language/cpsc-language-overview.7.md')
-rw-r--r--doc/language/cpsc-language-overview.7.md3
1 files changed, 2 insertions, 1 deletions
diff --git a/doc/language/cpsc-language-overview.7.md b/doc/language/cpsc-language-overview.7.md
index 559a58d..da4d821 100644
--- a/doc/language/cpsc-language-overview.7.md
+++ b/doc/language/cpsc-language-overview.7.md
@@ -10,7 +10,7 @@ Keywords are uppercase and case-sensitive. Ordinary identifiers, including built
Assign with ASCII `<-`: `Count <- Count + 1`. Compare with `=`, `<>`, `<`, `>`, `<=`, and `>=`. Standard-library STRING comparisons compare contents, case-sensitively. Use `+`, `-`, `*`, and `/` for arithmetic; built-in `/` always returns REAL. Use `&` to join strings.
-User-defined types can overload operators with OVERLOAD FUNCTION OPERATOR; expressions then use the declared result type. OVERLOAD definitions may also differ by return type: a context that requires a result type selects the matching return type, while a cast only prefers it. See [cpsc-keyword-operator(7)](keyword/cpsc-keyword-operator.7.md) and [cpsc-keyword-overload(7)](keyword/cpsc-keyword-overload.7.md). STRING cannot be implicitly converted to BOOLEAN. Typing is strict: arithmetic and unary minus accept only INTEGER and REAL, a comparison needs operands of the same type (or INTEGER with REAL), and BOOLEAN, CHAR and INTEGER never convert into one another implicitly (only INTEGER converts to REAL). Use ASC and CHR to move between CHAR and INTEGER. CHAR and STRING do convert implicitly: a CHAR becomes a one-character STRING in `&`, in comparisons, in assignment, in argument passing and in RETURN, and a STRING becomes a CHAR in assignment, argument passing and RETURN (for example `c <- MID(s, i, 1)`); a STRING whose length is not 1 is a runtime error that TRY/CATCH can catch. REAL never converts to INTEGER implicitly; use INT.
+User-defined types can overload operators with OVERLOAD FUNCTION OPERATOR; expressions then use the declared result type. OVERLOAD definitions may also differ by return type: a context that requires a result type selects the matching return type, while a cast only prefers it. `RETURNS DEFAULT type` selects a default when context cannot choose among return-only overloads. See [cpsc-keyword-operator(7)](keyword/cpsc-keyword-operator.7.md) and [cpsc-keyword-overload(7)](keyword/cpsc-keyword-overload.7.md). STRING cannot be implicitly converted to BOOLEAN. Typing is strict: arithmetic and unary minus accept only INTEGER and REAL, a comparison needs operands of the same type (or INTEGER with REAL), and BOOLEAN, CHAR and INTEGER never convert into one another implicitly (only INTEGER converts to REAL). Use ASC and CHR to move between CHAR and INTEGER. CHAR and STRING do convert implicitly: a CHAR becomes a one-character STRING in `&`, in comparisons, in assignment, in argument passing and in RETURN, and a STRING becomes a CHAR in assignment, argument passing and RETURN (for example `c <- MID(s, i, 1)`); a STRING whose length is not 1 is a runtime error that TRY/CATCH can catch. REAL never converts to INTEGER implicitly; use INT.
Precedence, from highest to lowest: unary operators, `* / DIV MOD`, `+ - &`, comparisons, AND, OR. Parentheses override precedence.
@@ -47,6 +47,7 @@ PP_DEFINE and PP_UNDEF control file-local, case-sensitive preprocessor switches.
- [cpsc-keyword-procedure(7)](keyword/cpsc-keyword-procedure.7.md): define a procedure and parameter modes.
- [cpsc-keyword-operator(7)](keyword/cpsc-keyword-operator.7.md): overload unary and binary operators.
- [cpsc-keyword-overload(7)](keyword/cpsc-keyword-overload.7.md): explicitly overload functions, procedures and constructors.
+- [cpsc-keyword-default(7)](keyword/cpsc-keyword-default.7.md): choose a default return type for an overload.
- [cpsc-keyword-template(7)](keyword/cpsc-keyword-template.7.md): define function, procedure and class templates with type packs.
- [cpsc-keyword-call(7)](keyword/cpsc-keyword-call.7.md): invoke a procedure.
- [cpsc-keyword-openfile(7)](keyword/cpsc-keyword-openfile.7.md): open a text file.