The latest Programming Redux video showcases new sharkC64 function return values with a creative flip-flap board animation example. This update to the C64-targeted language expands its capabilities by allowing functions to directly return values, opening the door for more flexible program design.
Demonstrating the New Feature
In the demonstration, the program clears the screen row by row, mimicking an old split-flap departure board. The process involves selecting a character to erase, adjusting it toward a blank space, and repeating until the row is empty. This is achieved using a set of functions—such as pick, replace, and clear_row—that now benefit from the newly introduced return values.
When a function returns a value, the language automatically creates a dedicated variable with the same name as the function. This variable can be read, written, and altered during execution, and its value is passed back when the function ends. The example also highlights the addition of a return statement, which ends a function immediately and sends back the current value of that variable.
Behind the Scenes in Compilation
The video walks through how return values integrate into sharkC64’s compilation process. The parser and binder have been updated to handle return types in function declarations and automatically manage the associated return value variables. In expressions, these functions work seamlessly, with the compiler fetching the stored return value after each call. Interestingly, no changes were needed in the intermediate representation’s bytecode output.
Looking Ahead
This enhancement brings sharkC64 closer to its first official release. Before that happens, usability testing will confirm the new feature’s stability and practicality. For those interested in modern programming tools built for the Commodore 64, this video offers both a technical breakdown and a satisfying visual demonstration.