Writing a Programming Language (in Rust) 7: Function calls (Part 3)
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.
Writing a Programming Language (in Rust) 7: Function calls (Part 3)
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
-
9
Writing a Programming Language (in Rust) 2: Branching, Literals and Addition28 viewsOct 24, 2021
-
7
Writing a Programming Language (in Rust) 6: Function calls (Part 2) This is episode 6 of the "Writing a Programming Language (in Rust)" livestrea...
-
6
Writing a Programming Language (in Rust) 9: Implementing Value References56 viewsDec 4, 20216DislikeShareSave
-
11
0:01 / 1:08:03 ...
-
8
0:00 / 2:05:26 ...
-
7
Writing a Programming Language (in Rust) 15: Implementing `this`68 viewsFeb 11, 20223DislikeShareSave
-
7
Writing a Programming Language (in Rust) 14: Compiler Resources and Function Argument Destructuring156 viewsFeb 1, 20229DislikeShare
-
6
Writing a Programming Language (in Rust) 13: Object Destructuring (Part 2) and Fixing Recursion223 viewsJan 29, 20227DislikeShare...
-
4
0:00 / 3:19:09 ...
-
12
0:00 / 2:28:52 ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK