5 ms·
I think it does, actually. When I took a Scheme class based on SICP, we implemented a Scheme interpreter as well as looking at an OOP system using lambdas. Wri
by tikhonj 15y ago
I think it does, actually. When I took a Scheme class based on SICP, we implemented a Scheme interpreter as well as looking at an OOP system using lambdas.
Writing that interpreter is the first time JavaScript's scoping rules made sense to me viscerally--they're exactly the same as Scheme's. The OOP system we used was also really similar to what you can do with JavaScript; it just used closures to save state. It wasn't exactly the same, but it was similar.
Ultimately, I find that JavaScript is much closer to Scheme than other dynamic scripting languages I've used like Python and Perl.
- groovy2shoes 15y agoJavaScript's scoping rules aren't the same as Scheme's -- variables are scoped at the function level rather than the block level.
- tikhonj 15y agoThat's how it works in Scheme too--you only get a new scope if you either have a lambda or an implicit lambda.
- groovy2shoes 15y agoSure, but in Scheme every block is an implicit lambda. In JavaScript, blocks are justs sections of code.