snow-deprecated
snow-deprecated copied to clipboard
Magic constants.
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.
The FILE should be __FILE__, of course. The iPhone keyboard doesn't have a backtick; sorry about that.
__FILE__ and __LINE__ are what people know, so why not. Also, they can be implemented directly in the parser with very little effort.
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.
I concur.
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'))
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!
As long as it gets a sensible string conversion, I'm all for it.