janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.52k stars 227 forks source link

repl.js redefining global methods #37

Closed toofar closed 5 years ago

toofar commented 5 years ago

On https://janet-lang.org/ repl.js defines methods in the global scope. In particular print() which ends up overriding window.print(). This probably wont break printing the page in browsers because they wouldn't use the JS API but it might break peoples custom scripts and is not good practice. Everything should be wrapped in an IIFE and anything you need accessable on window from elsewhere should be put there explicitly.

bakpakin commented 5 years ago

For all website related issues, open the issue in the https://github.com/janet-lang/janet-lang.org repo.

It doesn't really matter in this case. JavaScript "good practice" is for writing packages and large, JavaScript heavy websites. If a custom scripts break with unexpected globals, you need to fix your scripts. It's an easy enough fix though.