diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-01-01 15:30:52 +0100 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-01-01 15:30:52 +0100 |
commit | 16a9370e7f55eafdbe67dda3c84577d53494258b (patch) | |
tree | c6a5afc09368ec55e4674b2dfb57164c4c15af29 | |
parent | c990145e4dd7ca0e61f8ab5c1c906751df08e40d (diff) | |
download | uwu-nolambda-16a9370e7f55eafdbe67dda3c84577d53494258b.tar.xz |
Remove nolamda: prefix from function names
-rw-r--r-- | README.md | 52 | ||||
-rw-r--r-- | flow.c | 4 | ||||
-rw-r--r-- | fs.c | 8 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | os.c | 8 | ||||
-rw-r--r-- | random.c | 16 |
6 files changed, 46 insertions, 46 deletions
@@ -17,43 +17,43 @@ make uwu_include_path=/path/to/uwulang/repo ## Modules -Note: The module `nolambda:global` is not implemented yet. +Note: The module `global` is not implemented yet. -### `nolambda:flow` +### `flow` -- `nolambda:flow:linear`: Accepts an arbitrary number of arguments of arbitrary type, but at least one and evaulates all of them in order. Returns the last argument. -- `nolambda:flow:error`: Accepts an arbitrary type as $0, prints it to stderr appending a newline and exits the program with failure. Returns `:nil:nil` in theory. +- `flow:linear`: Accepts an arbitrary number of arguments of arbitrary type, but at least one and evaulates all of them in order. Returns the last argument. +- `flow:error`: Accepts an arbitrary type as $0, prints it to stderr appending a newline and exits the program with failure. Returns `:nil:nil` in theory. -### `nolambda:io` +### `io` -- `nolambda:io:print`: Accepts an arbitrary type as $0 and prints it to stdout, followed by a newline. Returns $0. -- `nolambda:io:scan`: Reads a line from stdin and returns it as a string, without the newline character at the end. If $0 is given, it is used as a prompt (after converting to string). +- `io:print`: Accepts an arbitrary type as $0 and prints it to stdout, followed by a newline. Returns $0. +- `io:scan`: Reads a line from stdin and returns it as a string, without the newline character at the end. If $0 is given, it is used as a prompt (after converting to string). -### `nolambda:fs` +### `fs` Note: all file paths are relative to the _directory the program was started from_. -- `nolambda:fs:read`: Accepts a file name (arbirary value, converted to string) as $0 and returns it's contents as a string. Causes an error if the file does not exist. -- `nolambda:fs:write`: Accepts a file name (arbirary value, converted to string) as $0 and overwrites it with the contents in $1 (arbirary value, converted to string). Causes an error if the file could not be written. Returns `:nil:nil`. -- `nolambda:fs:remove`: Accepts an arbitrary number of file names (arbirary type, converted to string), but at least one and unlinks them from the file system (the files can also be a directories). Causes an error if one of the file could not be removed, or if some or all of the files did not exist in the first place. Returns `:nil:nil`. -- `nolambda:fs:exists`: Accepts an arbitrary number of file names (arbirary type, converted to string), but at least one and returns `:bool:true` if all of them exist, `:bool:fase` else. +- `fs:read`: Accepts a file name (arbirary value, converted to string) as $0 and returns it's contents as a string. Causes an error if the file does not exist. +- `fs:write`: Accepts a file name (arbirary value, converted to string) as $0 and overwrites it with the contents in $1 (arbirary value, converted to string). Causes an error if the file could not be written. Returns `:nil:nil`. +- `fs:remove`: Accepts an arbitrary number of file names (arbirary type, converted to string), but at least one and unlinks them from the file system (the files can also be a directories). Causes an error if one of the file could not be removed, or if some or all of the files did not exist in the first place. Returns `:nil:nil`. +- `fs:exists`: Accepts an arbitrary number of file names (arbirary type, converted to string), but at least one and returns `:bool:true` if all of them exist, `:bool:fase` else. -### `nolambda:os` +### `os` -- `nolambda:os:exit`: Optionally takes an exit code (integer) as $0 and exits the program with the given exit code, or 0 if no exit code was given. Returns `:nil:nil` in theory. -- `nolambda:os:sleep`: Takes an integer as $0 and pauses the execution of the program for $1 milliseconds. Returns `:nil:nil`. -- `nolambda:os:execute`: Takes a command (arbirary value, converted to string) as $0 and executes it as a shell command. Returns the exit code of the command as an integer. -- `nolambda:os:time`: Returns the current unix millis as an integer. +- `os:exit`: Optionally takes an exit code (integer) as $0 and exits the program with the given exit code, or 0 if no exit code was given. Returns `:nil:nil` in theory. +- `os:sleep`: Takes an integer as $0 and pauses the execution of the program for $1 milliseconds. Returns `:nil:nil`. +- `os:execute`: Takes a command (arbirary value, converted to string) as $0 and executes it as a shell command. Returns the exit code of the command as an integer. +- `os:time`: Returns the current unix millis as an integer. -### `nolambda:global` +### `global` -- `nolambda:global:set`: Creates or overwrites a global variable named $0 (arbirary value, converted to string) and puts the contents of $1 (arbitrary type) into it. Returns `:bool:false` if the variable existed previously and was updated, `:bool:true` if it was created. -- `nolambda:global:get`: Returns the global variable named $0 (arbirary value, converted to string). Causes an error if the variable does not exist. -- `nolambda:global:exists`: Returns `:bool:true` if the global variable named $0 (arbirary value, converted to string) exists, `:bool:false` else. -- `nolambda:global:delete`: Deletes the global variable named $0 (arbirary value, converted to string). Returns `:bool:true` if the variable existed previously, `:bool:false` else. +- `global:set`: Creates or overwrites a global variable named $0 (arbirary value, converted to string) and puts the contents of $1 (arbitrary type) into it. Returns `:bool:false` if the variable existed previously and was updated, `:bool:true` if it was created. +- `global:get`: Returns the global variable named $0 (arbirary value, converted to string). Causes an error if the variable does not exist. +- `global:exists`: Returns `:bool:true` if the global variable named $0 (arbirary value, converted to string) exists, `:bool:false` else. +- `global:delete`: Deletes the global variable named $0 (arbirary value, converted to string). Returns `:bool:true` if the variable existed previously, `:bool:false` else. -### `nolambda:random` +### `random` -- `nolambda:random:random`: Returns a pseudorandom integer between $0 (integer) and $1 (integer). The range is inclusive on both boundse. Causes an error if the range is bigger than `nolambda:random:max` or empty. -- `nolambda:random:max`: Returns RAND_MAX. -- `nolambda:random:seed`: Sets the random seed to $0 (integer) and returns `:nil:nil`. +- `random:random`: Returns a pseudorandom integer between $0 (integer) and $1 (integer). The range is inclusive on both boundse. Causes an error if the range is bigger than `random:max` or empty. +- `random:max`: Returns RAND_MAX. +- `random:seed`: Sets the random seed to $0 (integer) and returns `:nil:nil`. @@ -8,7 +8,7 @@ UwUVMValue uwu_linear(UwUVMArgs *args) { - uwuutil_require_min("nolambda:flow:linear", args, 1); + uwuutil_require_min("flow:linear", args, 1); size_t return_arg = args->num - 1; @@ -20,7 +20,7 @@ UwUVMValue uwu_linear(UwUVMArgs *args) UwUVMValue uwu_error(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:flow:error", args, 1); + uwuutil_require_exact("flow:error", args, 1); char *err = uwustr_get(uwuvm_get_arg(args, 0)); fprintf(stderr, "%s\n", err); @@ -11,7 +11,7 @@ UwUVMValue uwu_read(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:fs:read", args, 1); + uwuutil_require_exact("fs:read", args, 1); char *filename = uwustr_get(uwuvm_get_arg(args, 0)); @@ -36,7 +36,7 @@ UwUVMValue uwu_read(UwUVMArgs *args) UwUVMValue uwu_write(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:fs:write", args, 2); + uwuutil_require_exact("fs:write", args, 2); char *filename = uwustr_get(uwuvm_get_arg(args, 0)); char *contents = uwustr_get(uwuvm_get_arg(args, 1)); @@ -56,7 +56,7 @@ UwUVMValue uwu_write(UwUVMArgs *args) UwUVMValue uwu_remove(UwUVMArgs *args) { - uwuutil_require_min("nolambda:fs:remove", args, 1); + uwuutil_require_min("fs:remove", args, 1); for (size_t i = 0; i < args->num; i++) { char *filename = uwustr_get(uwuvm_get_arg(args, i)); @@ -71,7 +71,7 @@ UwUVMValue uwu_remove(UwUVMArgs *args) UwUVMValue uwu_exists(UwUVMArgs *args) { - uwuutil_require_min("nolambda:fs:exists", args, 1); + uwuutil_require_min("fs:exists", args, 1); for (size_t i = 0; i < args->num; i++) { char *filename = uwustr_get(uwuvm_get_arg(args, i)); @@ -9,7 +9,7 @@ UwUVMValue uwu_print(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:io:print", args, 1); + uwuutil_require_exact("io:print", args, 1); UwUVMValue value = uwuvm_get_arg(args, 0); @@ -22,7 +22,7 @@ UwUVMValue uwu_print(UwUVMArgs *args) UwUVMValue uwu_scan(UwUVMArgs *args) { - uwuutil_require_max("nolambda:io:scan", args, 1); + uwuutil_require_max("io:scan", args, 1); char *prompt = NULL; @@ -10,7 +10,7 @@ UwUVMValue uwu_exit(UwUVMArgs *args) { - uwuutil_require_max("nolambda:os:exit", args, 1); + uwuutil_require_max("os:exit", args, 1); long exit_code = 0; @@ -23,7 +23,7 @@ UwUVMValue uwu_exit(UwUVMArgs *args) UwUVMValue uwu_sleep(UwUVMArgs *args) { - uwuutil_require_exact("nolamda:os:sleep", args, 1); + uwuutil_require_exact("os:sleep", args, 1); UwUVMValue value = uwuvm_get_arg(args, 0); @@ -49,7 +49,7 @@ UwUVMValue uwu_sleep(UwUVMArgs *args) UwUVMValue uwu_execute(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:os:execute", args, 1); + uwuutil_require_exact("os:execute", args, 1); char *command = uwustr_get(uwuvm_get_arg(args, 0)); int ret = system(command); @@ -60,7 +60,7 @@ UwUVMValue uwu_execute(UwUVMArgs *args) UwUVMValue uwu_time(UwUVMArgs *args) { - uwuutil_require_exact("nolamda:os:time", args, 0); + uwuutil_require_exact("os:time", args, 0); struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); @@ -7,17 +7,17 @@ UwUVMValue uwu_random(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:random:random", args, 2); + uwuutil_require_exact("random:random", args, 2); UwUVMValue value0 = uwuvm_get_arg(args, 0); if (value0.type != &uwuint_type) - error("type error: nolamda:random:random requires an integer as $0\n"); + error("type error: random:random requires an integer as $0\n"); UwUVMValue value1 = uwuvm_get_arg(args, 1); if (value1.type != &uwuint_type) - error("type error: nolamda:random:random requires an integer as $1\n"); + error("type error: random:random requires an integer as $1\n"); long min = uwuint_get(value0); long max = uwuint_get(value1) + 1; @@ -25,28 +25,28 @@ UwUVMValue uwu_random(UwUVMArgs *args) long range = max - min; if (range < 0) - error("type error: range passed to nolambda:random:random is empty\n"); + error("type error: range passed to random:random is empty\n"); if (range > RAND_MAX) - error("type error: range passed to nolambda:random:random is bigger than nolambda:random:max"); + error("type error: range passed to random:random is bigger than random:max"); return uwuint_create(min + rand() % range); } UwUVMValue uwu_max(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:random:max", args, 0); + uwuutil_require_exact("random:max", args, 0); return uwuint_create(RAND_MAX); } UwUVMValue uwu_seed(UwUVMArgs *args) { - uwuutil_require_exact("nolambda:random:seed", args, 1); + uwuutil_require_exact("random:seed", args, 1); UwUVMValue value = uwuvm_get_arg(args, 0); if (value.type != &uwuint_type) - error("type error: nolamda:random:seed requires an integer as $0\n"); + error("type error: random:seed requires an integer as $0\n"); srand(uwuint_get(value) % RAND_MAX); return uwunil_create(); |