From 5c04edc5fb64419bdc25481b5669928cad6cab1c Mon Sep 17 00:00:00 2001 From: Logikoma Date: Wed, 5 Aug 2026 17:04:26 -0400 Subject: [PATCH] Document environment variable creation helpers --- src/environment.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/environment.c b/src/environment.c index b2bdc9b..f54561a 100644 --- a/src/environment.c +++ b/src/environment.c @@ -364,6 +364,14 @@ static akerr_ErrorContext *environment_create_named(akbasic_Environment *obj, co SUCCEED_RETURN(errctx); } +/** + * @brief Find a variable in this scope, creating and initializing it if absent. + * + * @param obj The scope to search and, on a miss, to create in. + * @param varname Name including its type suffix. + * @param dest Output destination populated with the variable. + * @return `NULL` on success, otherwise an error context owned by the caller. + */ akerr_ErrorContext *akbasic_environment_create(akbasic_Environment *obj, const char *varname, akbasic_Variable **dest) { PREPARE_ERROR(errctx); @@ -372,6 +380,16 @@ akerr_ErrorContext *akbasic_environment_create(akbasic_Environment *obj, const c SUCCEED_RETURN(errctx); } +/** + * @brief Find a variable in this scope, creating it without value storage if absent. + * + * The caller must initialize the variable before evaluating it. + * + * @param obj The scope to search and, on a miss, to create in. + * @param varname Name including its type suffix. + * @param dest Output destination populated with the variable. + * @return `NULL` on success, otherwise an error context owned by the caller. + */ akerr_ErrorContext *akbasic_environment_create_empty(akbasic_Environment *obj, const char *varname, akbasic_Variable **dest) {