From 9ae515d181e20d5901a569a49435b24383bba97d Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Fri, 17 Feb 2023 00:37:07 +1100 Subject: [PATCH] Added Toy_parseIdentifierToValue --- c-api/toy_interpreter_h.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/c-api/toy_interpreter_h.md b/c-api/toy_interpreter_h.md index 7bb2f05..da3e499 100644 --- a/c-api/toy_interpreter_h.md +++ b/c-api/toy_interpreter_h.md @@ -63,7 +63,14 @@ This utility function will find a `Toy_literal` within the `Toy_Interpreter`'s s ### bool Toy_parseIdentifierToValue(Toy_Interpreter* interpreter, Toy_Literal* literalPtr) -Note: Bugfixes related to this function are currently in prgress. +Sometimes, native functions will receive `Toy_Literal` identifiers instead of the values - the values can be retreived from the given interpreter's scope using the following pattern: + +```c +Toy_Literal foobarIdn = foobar; +if (TOY_IS_IDENTIFIER(foobar) && Toy_parseIdentifierToValue(interpreter, &foobar)) { + freeLiteral(foobarIdn); //remember to free the identifier +} +``` ### void Toy_setInterpreterPrint(Toy_Interpreter* interpreter, Toy_PrintFn printOutput)