Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

by likbez (Sexton)
on Sep 11, 2020 at 14:20 UTC ( #11121615=note: print w/replies, xml ) Need Help??


in reply to Re^5: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
in thread What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff

In the following, the first line has a balance of brackets and looks syntactically correct. Would you expect the lexer to add a semicolon?
  $a = $b + $c
            + $d + $e;
Yes, and the user will get an error. This is similar to previous example with trailing on a new line

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

The first question is why he/she wants to format the code this way if he/she suffers from "missing semicolons" problem, wants to avoid missing semicolon error and, supposedly deliberately enabled pragma "softsemicolons" for that?

This is the case where the user need to use #\ to inform the scanner about his choice. But you are right in a sense that it creates a new type of errors -- "missing continuation." And that there is no free lunch. This approach requires specific discipline to formatting your code.

  • Comment on Re^6: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
  • Download Code

Replies are listed 'Best First'.
Re^7: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by dave_the_m (Monsignor) on Sep 11, 2020 at 14:52 UTC
    How would the parser know to give a "missing continuation" error message? '+$d+$e' is perfectly legal perl code, albeit code which gives rise to the warning "Useless use of addition (+) in void context".

    The reason I gave that code as an example is that it's a perfectly normal way of spreading complex expressions over multiple lines: e.g. where you need to add several variables together and the variables have non-trivial (i.e. long) names, e.g.

    $pressure = $partial_pressure_nitrogen + $partial_pressure_oxygen + $partial_pressure_water_vapour + $partial_pressure_argon + $partial_pressure_carbon_dioxide;
    In this case, the automatic semicolons are unhelpful and will give rise to confusing error messages. So you've just switched one problem for another, and raised the cognitive load - people now need to know about your pragma and also know when its in scope.

    Dave.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^7: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by Tux (Abbot) on Sep 12, 2020 at 09:38 UTC

    You also completely ruin maintainability and extensibility. Consider a filter module ...

    my $fixed = $bad =~ y/\x{00d0}/\x{0110}/r # Eth != D-stroke =~ y/\x{0189}/\x{0110}/r # LETTER AFRICAN D != +D-stroke =~ s{\bpra[ck]ti[sc]e\b}{practice}gr # All 4 seen in docume +nt AB12.38C =~ s{\bX13\.GtrA\.14\b}{X13_GA12}gr # Product got renamed =~ s{\b1234\s*zip\b}{1234ZIP}gir # Reciever will crash +on badly formed ZIP code =~ s{\bpays\s*-?\s*bas\b} {The Netherlands}gir # French forms :( =~ ....;

    The more examples I see posted by my esteemed co-monks, the less I like the idea, and I hated it already when I read it in the OP.


    Enjoy, Have FUN! H.Merijn
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re^7: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by ikegami (Pope) on Sep 14, 2020 at 22:11 UTC

    Yes, and the user will get an error.

    Then your suggestion would break a very useful feature. So useful that I take advantage of it in virtually every one of my programs/modules.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2020-11-28 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?