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

Re: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

by Corion (Patriarch)
on Sep 10, 2020 at 07:03 UTC ( [id://11121539]=note: print w/replies, xml ) Need Help??


in reply to What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

Highly desirable Make a semicolon optional at the end of the line, if there is a balance of brackets on the line and the statement looks syntactically correct ("soft semicolon", the solution used in famous IBM PL/1 debugging compiler).

Why would this be highly desirable? Consider:

print( "Hello World" ) if( 1 );

versus

print( "Hello World" ) if( 1 < 2 ) { print("Goodbye"); };

Adding your change idea makes the parser even more complex and introduces weird edge cases.

I think even Javascript now recommends using semicolons instead of eliding them at the end of a line.

Update: Some examples where ASI in Javascript goes wrong:

Replies are listed 'Best First'.
Re^2: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by dsheroh (Monsignor) on Sep 10, 2020 at 09:07 UTC
    Even aside from that, some of us don't like really long lines of code. Having to scroll horizontally in GUI editors sucks, and I do most of my coding in good-old 80-column terminal windows. So it's not uncommon for me to split up a long statement into multiple shorter lines, since whitespace has no syntactic significance.

    If CRLF becomes a potential statement terminator, then breaking a single statement across multiple lines not only becomes a minefield of "will this be treated as one or multiple statements?", but the answer to that question may change depending on where in the statement the line breaks are inserted!

    If implemented, this change would make a mockery of any claims that Perl 7 will just be "Perl 5 with different defaults", as well as any expectations that it could be used to run "clean" (by some definition) Perl 5 code without modification.

      If implemented, this change would make a mockery of any claims that Perl 7 will just be "Perl 5 with different defaults", as well as any expectations that it could be used to run "clean" (by some definition) Perl 5 code without modification.
      Looks like a valid objection. I agree. With certain formatting style it is possible. But do you understand the strict as the default will break a lot of old scripts too. Per your critique, it probably should not be made as the default and implemented as pragma similar to warnings and strict. Let's call this pragma "softsemicolon"

      What most people here do not understand is it can be implemented completely on lexical scanner level, not affecting syntax analyser.

        But do you understand the strict as the default will break a lot of old scripts too.
        Yes, that falls under my earlier statement about "expectations that it could be used to run "clean" (by some definition) Perl 5 code without modification." "Clean" Perl 5 code (by almost all definitions) already uses strict, so enabling strict by default will not break it.

        Backslash-escaped line endings are not currently recommended to be included in "clean" Perl 5 code. Indeed, they are not currently a part of the language at all. Thus, requiring them (even if only for some subset of mid-statement linebreaks) is something that will break existing "clean" code.

        What most people here do not understand is it can be implemented completely on lexical scanner level, not affecting syntax analyser.
        And what, exactly, does that have to do with anything? The change will be backwards-incompatible and break existing code. Whether it's broken by the lexical scanner or broken by the syntax analyzer is completely irrelevant. The code won't run either way.

        As I understand it, the current thinking is that the strict-by-default feature will just be the same strict-by-default feature that has existed since Perl 5.12.

        So a use v7; will turn on strictures, but if a script doesn't have a version declaration, it won't default to strict.

        If implemented this way, it has no chance of breaking old scripts.

        What most people here do not understand is it can be implemented completely on lexical scanner level, not affecting syntax analyser.
        While I do not trust that assessment, it is also completely irrelevant. The question is not whether it can be implemented, but whether it should be implemented. You have received sufficient feedback that other monks agree that it should not.
    A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-28 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found