8

Writing a Programming Language (in Rust) 7: Function calls (Part 3)

 2 years ago
source link: https://www.youtube.com/watch?v=nyQLenFK4Xc
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Writing a Programming Language (in Rust) 7: Function calls (Part 3)

87 views
Nov 14, 2021

This is episode 7 of the "Writing a Programming Language (in Rust)" livestream series, where I'll be implementing a skeleton C-style programming language from scratch using Rust and LALRPOP.

The live stream is ongoing at https://www.twitch.tv/ezanmoto. I generally stream at 14:00 GMT each Saturday.

The source code for the stream is available at https://github.com/eZanmoto/norpl.

In this session I was implementing the following features:

* Updating the scoping approach from dynamic scoping to lexical scoping * Rename `Frame` to `Scope` and `Env` to `ScopeStack` * Update functions to have their scope stack defined based on the definition site of the function, rather than the call site; i.e. implementing closures * Introduce a new scope in each new block 1:12:40 Introducing a declaration syntax (`:=`) to use alongside the assignment syntax (`=`) * Renaming the `assign` function to `bind`, to allow for handling both assigment and declarations

In addition there was a considerable time in this session spent on the following topics:

0:56:35 Answering the chatroom: Discussing the Norpl language and its goals, including the future goal of being an alternative to the Bash (shell) scripting language, where the ergonomics of shell scripting are kept but are supported by more modern programming mechanisms for manipulating data. 1:08:03 Answering the chatroom: Why Rust was used for this project. * Attempting to use a closure to handle the "bind" logic based on whether the binding was an assigment or a declaration, but had to remove it due to difficulties with the borrow checker. 1:59:35 Updating the bind logic to use a boolean flag instead of a closure. 2:16:24 Demonstrating the current function functionality. 2:18:50 Correcting the iteration order through the scope stack 2:27:43 Recap of the next steps for the language. 2:31:10 Attempting to remove the need for a separate `eval_prog` function, but ended up reverting the change.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK