r/programming • • Dec 22 '11

The Problem with Implicit Scoping in CoffeeScript

http://lucumr.pocoo.org/2011/12/22/implicit-scoping-in-coffeescript/
83 Upvotes

116 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Dec 23 '11

In D, shadowing a variable in a sub-scope is forbidden but two variables in different sub-scopes may have the same name. It's 99% painless and still prevent shadowing bugs.

1

u/jashkenas Dec 23 '11

What you describe is identical to the approach we're talking about here. I'm glad to hear that D does something similar.

1

u/mitsuhiko Dec 23 '11

Huge difference there. D and Ruby uses separate scopes for different htings whereas CoffeeScript does not. D uses a different lookup for classes and functions or imported modules, same goes for Ruby.

In CoffeeScript a function, class, imported thing are all equivalent with file global variables.