Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Why does eof have a prototype?

by ikegami (Patriarch)
on Aug 08, 2022 at 18:08 UTC ( #11146031=note: print w/replies, xml ) Need Help??

in reply to Why does eof have a prototype?

Two reasons I can think of:

  • So it can be overridden. As I remember it, prototypes were added to ops as part of making them overridable.
  • It was done by accident (i.e. without knowledge the prototype was inadequate).

Replies are listed 'Best First'.
Re^2: Why does eof have a prototype?
by Anonymous Monk on Aug 08, 2022 at 19:04 UTC
    the prototype was inadequate

    how so?

      That certain operators (eof, open, etc.) have prototypes that aren't adequate for representing the syntax of the operator is the premise of the question.

      For example,

      • An overridden eof operator can't distinguish whether it was was called as eof or eof() while the real operator does.

      • open( STDERR , ">&=", STDOUT ) is perfectly valid with the real operator, but throws a strict error with an overridden open.

        $ perl <<'.' use strict; open( STDERR , ">&=", STDOUT ); BEGIN { *CORE::GLOBAL::open = sub (*;$@) { } } open( STDERR , ">&=", STDOUT ); . Bareword "STDOUT" not allowed while "strict subs" in use at - line 4. Execution of - aborted due to compilation errors.

      Upd: Fixed accidental double negation.

        Filehandles are still too voodoo for me, I hoped something like this could fix that problem...

        use constant STDERR => \*STDERR; use constant STDOUT => \*STDOUT;

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146031]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (1)
As of 2023-06-07 20:07 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.