From 2c4324670ff569ede360d13875c5e4b5720a626d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 5 Mar 2025 11:35:53 -0500 Subject: [PATCH] Add print() as alias for say() --- docs/README.md | 21 +++++++++++++++++++++ environment.c | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/docs/README.md b/docs/README.md index d427dee..4bfc2e1 100644 --- a/docs/README.md +++ b/docs/README.md @@ -90,6 +90,27 @@ exit(status=1, "Goodbye forever!") --- +### `print` +Prints a message to the console (alias for [`say`](#say)). + +```tomo +func print(text:Text, newline:Bool = yes -> Void) +``` + +- `text`: The text to print. +- `newline`: Whether or not to print a newline after the text. + +**Returns:** +Nothing. + +**Example:** +```tomo +print("Hello ", newline=no) +print("world!") +``` + +--- + ### `say` Prints a message to the console. diff --git a/environment.c b/environment.c index 093b8c7..3b4bb62 100644 --- a/environment.c +++ b/environment.c @@ -36,6 +36,10 @@ env_t *new_compilation_unit(CORD libname) FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE, .next=new(arg_t, .name="newline", .type=Type(BoolType), .default_val=FakeAST(Bool, true))), .ret=Type(VoidType))}}, + {"print", {.code="say", .type=Type( + FunctionType, .args=new(arg_t, .name="text", .type=TEXT_TYPE, + .next=new(arg_t, .name="newline", .type=Type(BoolType), .default_val=FakeAST(Bool, true))), + .ret=Type(VoidType))}}, {"ask", {.code="ask", .type=Type( FunctionType, .args=new(arg_t, .name="prompt", .type=TEXT_TYPE, .next=new(arg_t, .name="bold", .type=Type(BoolType),