| In message "[ruby-talk:02034] class File acting funny!"
|     on 00/03/20, "David Douthitt" <DDouthitt / cuna.com> writes:
| 
| |Designing my own iterators isn't a problem, but this lock class seems
| |to be.  I get many funny errors:
| 
| |   * Lock.new insisted on 1 parameter - but initialize method
| |     had NO parameters
| 
| First of all, IO and its subclasses does not call `initialize' yet.

Aha!

| |   * $0 was not being recognized in parameter default value expressions
| 
| It works on my machine:

Is there a limit to the complexity of expressions used as default
values?

| |   * $stdio evaluates to nil
| 
| There's no $stdio predefined, but $stdin, $stdout, $stderr.

I KNEW there had to be a dumb mistake in there somewhere :-)

| |   * flock appears to fail on non-existant files (?) and says in the
| |     documentation "advisory" lock.... 
| 
| See `man 2 flock' if you're using UNIX box.  Advisory lock requires
| a file to be exist.

Ugh.  I shifted gears and went to using (with ksh or posix)
system("set -o noclobber ; cat /dev/null > #{lockf} 2> /dev/null")
and did NOT subclass IO.  Now it WORKS.

| Two work arounds:
| 
|   (a) Wait until IO calls `initialize', somewhere in this month I
|       think.
| 
|   (b) Use delegator, e.g.
| 
|          require 'delegate
| 
|          class Lock<DelegateClass(IO)
|             attr_accessor :locked, :lockdir, :lockfile
|             ...
|          end

These sound like 1.5-isms.  Am I the only one using 1.4.3?

Thanks for the help and info!