In a shadow of the globals

While working on void and later true and false I realized I would like to make those names reserved, despite the fact they are not keywords. It seemed odd — I made an arbitrary decision because void was so ubiquitous. Or because it was placed in global namespace? It was so lame, definition of void looked like any other object, and yet out of the blue it was selected by me that it should be reserved name. What if another object happens to be that important, should I also hard code its name into compiler to make it reserved as well?

Or was it global namespace indeed? And that was all it mattered?

There are plenty of languages which allow you to put a function, a variable into a global namespace with typical advice that you should keep global entities to minimum. Skila was one of those languages.

But not any longer, add as many variables to global namespace as you like.

Yes, sure, go ahead.

Just keep in mind shadowing of namespaces in Skila is disabled. It is a trick which solves my dilemmas about making arbitrary decision with names, and it also enforces the discipline of polluting the namespaces, no more talking, just rules. Take a look how it works:

namespace DirtyPlayground
  let x Int = 5; 
  
  def func(x Int) // error
    •••  
  end
end

The first x effectively makes a reservation for its name for entire namespace (and its descendants), thus you cannot shadow it by declaring any local variable.

Tagged ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: