On Mon, Dec 15, 2008 at 6:59 PM, Leon Timmermans <faw...@gmail.com> wrote:
> On Mon, Dec 15, 2008 at 6:42 PM, jason switzer <jswit...@gmail.com> wrote: > > It's lazy and kinda cheating, but for small simple tasks, it gets the job > > done. I'm not up to speed with the IO spec, but a sort of auto-slurp > > functionality would be nice. Something to the effect: > > > > @data = :slurp("mydatafile.txt"); > > A slurp() function has been specced to slurp a file into a string, as > well as a lines() function that does the same into an array of lines. > Okay, that's good to know. > You didn't get the point of my Roles idea. It should not be added to a > role File, but to the Role Nameable, which would be composed into > whatever implements file filehandles, but for example also into Unix > sockets. IMNSHO interfaces and implementation should be kept separate > to maintain a proper abstraction level. > I hadn't seen a Nameable role mentioned yet, so I wasn't able to understand any such concept. That is a good idea, but the idea is so general that anything can be nameable and thus the specificity of the role could quickly become lost. I was suggesting specific naming functionalities be added to the File role. If you want to abstract that, that's fine, but beware that something like Nameable can be too broad of a role (maybe just IONameable?). > You can already easily mix it in using 'does': > > $fstab = open('/etc/fstab', :r); > $fstab does WhitespaceTrim; > > I don't think it's really necessary to include that into open(), > though it might be useful syntactic sugar. I haven't spent the time to understand mix-ins yet, but this does look like a feasible (clean) idea. However, how do you specify one/more filters? For example, say you want to :rw a file. How can you provide an input filter and an output filter (or multiples of either)? Can you layer filters if done with mix-ins? If so, how do you specify direction? -Jason "s1n" Switzer