Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
eof(); and eof; are (magically) different syntax for eof, and this difference can't be expressed with prototypes.

I'm not sure this is a job for prototypes. Every Perl function can be called with and without parens (given the compiler knows about it), it's always valid syntax. The trick would be to detect inside a hypothetical sub myeof whether the parens are there are not - how would one do this with prototypes? Seems more like a job for something like caller. It's also worth noting that AFAIK eof is the only function in Perl that behaves this way... the exception that confirms the rule ;-)

Interesting side note: see eof in perltie.

A "can be parsed without errors" criteria is not enough for me.

I don't think that's the criteria. It's more like: "Every variation of the builtin's syntax can be expressed by prototypes" - look at threads like Prototype like sort()? where everyone's implementations got close to the original, but noone was able to replicate all of sort's syntax. All of eof's syntax can be replicated, but not its functionality. That's where the difference is.

I do understand how you are interpreting that piece of documentation, but I think you should cut the authors some slack :-) eof is a unique case, and knowing this, I don't think that passage is inaccurate.

In reply to Re^3: Why does eof have a prototype? by haukex
in thread Why does eof have a prototype? by LanX

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-06-18 13:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.