From: Hans Fugal Date: 2004-08-05T04:46:29+09:00 Subject: Re: YAML.load(ARGF) I agree it doesn't always make sense, maybe not even often, but sometimes it does. There's nothing that says a yaml document has to reside in one file, and there's certainly good reason to take it in on stdin. Robert Klemme wrote: > "Austin Ziegler" schrieb im Newsbeitrag > news:9e7db91104080410463cea4c22@mail.gmail.com... > >>On Thu, 5 Aug 2004 02:36:29 +0900, Hans Fugal wrote: >> >>>Consider these two short programs: >>> ARGF.read >>>and >>> require 'yaml' >>> YAML.load(ARGF) >>> >>>Then call them like so: >>> >>> $ ruby foo.rb foo >>> >>>The first program prints the contents of foo and exits. The second >>>program waits for ^D from the terminal, and then tries to parse the YAML >>>and go on with life. >>> >>>I want ARGF to behave like it does in the first example, in the second >>>example. Of course I could do YAML.load(ARGF.read) but that doesn't >>>satisfy my curiousity. :-) >> >>IMO, YAML.load *should* do this with ARGF because the following works: >> >> f = File.open("foo", "rb") >> YAML.load(f) >> f.close > > > Not so fast: ARGF is quite special. It's especially *no* an IO. It just > happens to implement some methods of IO. IMHO it's not reasonable to invoke > YAML.load(ARGF) because ARGF might draw its data from any number of files - > including stdin. IMHO it's not very practical to distribute YAML data > across multiple files. The case is differnt for grep like tools that can > reasonable operate on a multitude of files. > > Just my 0.02EUR... > > Kind regards > > robert >