Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why scripting languages use dynamic scope rule?

do any one know why scripitng languages use dynamic scope rule ? I can not find any thing about this matter on the Internet.

like image 732
Amir Pouya Avatar asked Dec 07 '22 00:12

Amir Pouya


2 Answers

Scripting languages generally do not have dynamic scoping. Scheme, Lua, Ruby, and Python are all lexically scoped. Only a few languages still around use dynamic scope because it makes it painfully hard to reason about what your code is doing by looking at it.

When you say "dynamic scoping" what are you trying to describe?

like image 163
munificent Avatar answered Dec 09 '22 12:12

munificent


Partly because they can. Scripting languages already have substantial overhead to access variables compared to compiled languages. Adding dynamic scoping is easy, as is adding fun features like closures.

like image 41
Alex Brown Avatar answered Dec 09 '22 12:12

Alex Brown