simonask / snow-deprecated

(ATTENTION WATCHERS: This repository is deprecated. Please watch 'snow' instead.) Snow is a simple, dynamic, and expressive programming language with an emphasis on speed and simplicity. Snow is fully object-oriented, and fully function-oriented at the same time.
http://snow.meta.io/
Other
21 stars 1 forks source link

Magic constants. #36

Open Mikoangelo opened 15 years ago

Mikoangelo commented 15 years ago

Snow needs a way to dynamically refer to the current file, directory, line, and preferably function name (currently problematic).

I think FILE et al works fine, albeit slightly un-Snowy.

Mikoangelo commented 15 years ago

The FILE should be __FILE__, of course. The iPhone keyboard doesn't have a backtick; sorry about that.

simonask commented 15 years ago

__FILE__ and __LINE__ are what people know, so why not. Also, they can be implemented directly in the parser with very little effort.

Mikoangelo commented 15 years ago

Alright, I'm all for it. Up for consideration are also $file/$FILE and $line/$LINE.

Regardless, I think we should preemptively answer people's prayers by making __DIR__ as well. I can't tell you how many times I've heard that plea from foaming hordes of Rubyists, tired of writing File.dirname(__FILE__) all the time.

simonask commented 15 years ago

I concur.

judofyr commented 15 years ago

It would also be nice if __FILE__ and __DIR__ was a Pathname (or something similar to Ruby's Pathname) instead of a String, so we could do things like:

require(__DIR__.parent.join('lib', 'lib'))
Mikoangelo commented 15 years ago

I concur with Judofyr. My experience in Ruby is that these are by far used enough to warrant wrapping that string in a more semantic class to ease manipulation.

We need a Pathname class in stdlib, pronto!

simonask commented 15 years ago

As long as it gets a sensible string conversion, I'm all for it.