ingydotnet/io-all-pm — Issue #10: Assume File for Filesys methods on non-existent files
Author: ranguard
Created: 2011-11-02 08:47:17+00:00
State: open

# Works well
io('/tmp/exists.txt')->filename; # exists.txt

# Goes BOOM...
io('/tmp/does_not_exist.txt')->filename; # Can't find a class for method 'filename'

04:59 < ingy> io(...) looks at ... to guess what type of object to create
04:59 < ingy> it bless the object into the appropriate class
04:59 < ingy> it does it lazily, iirc
05:00 < ingy> so '/tmp/does_not_exist.txt' doesn't know what to do
05:00 < ingy> so it gets a hint from filename
05:01 * ingy looks at the code...
05:01 < ingy> right
05:02 < ingy> so filename is a method of IO::All::Filesys
05:02 < ingy> which is a base class for IO::All::File *and* IO::All::Dir
05:02 < ingy> so it still doesn't know what to make of it
05:02 < ingy> kinda sucks, I agree
05:03 < ingy> I guess we can make it assume File for Filesys methods where ... does not -e