Eryq wrote:
 
> And all that I am saying is that this syntactic complication,
> this special case where "the filehandle name *is* the object",
> should be gotten rid of.  Unlike some other special Perl syntactic
> constructs (e.g., regular expressions, "here-is" documents),
> the current filehandle syntax does not add anything of value to the
> language, and yet it has caused a lot of confusion when new Perlers
> try to pass filehandles around between packages, and they don't
> yet know about globs.


Given the chance and inclination, I have been tending to argue in these
forums that we might embrace these "name is the object" situations and
allow other creatures besides filehandles that do not easily slip into
numbers or text strings to occur in our new versioned language without
their decorations too.

Decorated variables ("scalars" "arrays" and "hashes") have well defined
conversion functions.  If I want to have a limited type that does not
convert, for instance a strictly integer type, currently I can do that
with "tie" which is clumsy and which does not "travel" well.

Filehandles are such a thing, they do not travel well.  Beginners try to
pass them as subroutine arguments and so on.

Why not accomodate this ubiquitous beginner usage?  We could allow all
nondecorated variables (file handles, and other things too) to instantly
convert into blessed references to themselves when they get assigned to
scalars or passed into subroutines that do not explicitly expect such
things?

My counterproposal, which I may write into a late RFC but which I hope
may be communicated as needed from the several discussion postings I have
made expressing this point of view more or less, to the coercion of 
file handles into scalars, is thus:

        :: We allow arbitrary user-defined nondecorated types.

        :: On inclusion in an argument list a user-defined nondecorated variable
becomes a blessed reference to itself.

        :: (On inclusion in an argument list a file handle becomes a blessed reference
to itself.)

        :: what a nondecorated type returns when you try to assign it to a scalar
is up to it, but might default to a blessed reference.

        :: what a nondecorated type does when you assign to it from a scalar is
entirely up to the type.


If we

--
                          David Nicol 816.235.1187 [EMAIL PROTECTED]
       Accept no substitutes, insist on Genuine Original Snake Oil

Reply via email to