Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Note to zealots who consistently put negative ratings on my comments:
I do not care, but you prevent people who are not logged to the site from reading them and as such you censor my speech. Please remove them. This is a free forum not your clique watering place. The fact that you are unable to appreciate or understand them does not mean that they have no value to other people. Not all users here are Perl zealots. As Prince Talleyrand recommended to young diplomats: first and foremost not too much zeal. This is fully applicable to Perl advocacy. On other words by behaving like a clique you are harming Perl acceptance and future.
What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff. I compiled some my suggestions and will appreciate the feedback:
  1. [Edited] [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 (optional pragma "soft semicolon", similar to the solution used in famous IBM PL/1 debugging compiler). That can help sysadmins who use bash and Perl in parallel and work from command line with vi or similar editors, and are not using such editors as Komodo Edit which flag syntax errors. If might make sense to enable this pragma only via option -d of the interpreter. In this case it will suit as a pure debugging aid, cutting the number of iterations of editing the source before actual run. It does not make much sense to leave statements without semicolons in the final, production version of the program. See, for example, the discussion in Stack Overflow Do you recommend using semicolons after every statement in JavaScript
  2. [Highly Questionable] Introduce pragma that specify max allowed length of single and double quoted string (but not any other type of literals). That might simplify catching missing quote (which is not a big problem with any decent Perl aware editor anyway)
  3. [Highly desirable] Compensate for some deficiencies of using curvy brackets as the block delimiters:
    1. Treat "}:LABEL" as the bracket closing "LABEL:{" and all intermediate blocks (This idea was also first implemented in PL/1). [Edited]This feature also makes complex nesting structures more reliable, and can't be compensated with the editor, as people often just forget to check and assume that a complex nesting structure is OK, while in reality it is not. Some people argue that complex nesting structures should not exist. Those should not use this feature at all, but we should not allow them to dictate how we should program our scripts, especially in areas they have no clue about. For example, hand-written lexical and syntax analyzers and similar scripts with recursion and a very complex decision making.
    2. [Edited]Treat "}.." symbol as closing all opened brackets up to the subroutine/BEGIN block level and }... including this level (closing up to the nesting level zero. ). Along with conserving vertical space, this allows search for missing closing bracket to be more efficient. It might be possible to treat them as macros, which interpreter expands in the source code to regular brackets. Like soft-semicolons this feature mainly benefits those who use command like and vi, not some sophisticated GUI editor and allows dramatically cut the area of search for missing bracket in long scripts. .
  4. Make function slightly more flexible:
    1. Introduce pragma that allows to define synonyms to built-in functions, for example ss for for substr and ix for index
    2. Allow default read access for global variables with subroutines, but write mode only with own declaration via special pragma, for example use sunglasses;
    3. Introduce inline functions which will be expanded like macros at compile time:
      sub subindex inline{ $_[0]=substr($_[0],index($_[0],$_[1],$_2])) }
  5. As extracting of sub-string is a frequent operation in text processing scripts (for example to limit the scope of index function, or regular expression) in many cases it is more convenient to have indexes of starting and ending symbols, not a starting symbol and length. Also extracting of a sub-string sometimes is performed by eliminating head and tail with particular sets of characters like in tr/.../.../d ; often those characters are white space, a frequent operation for which something less general then regex might be beneficial.
    1. Adopt "range" notation. Allow to extract a sub-string via : or '..' notations like $line [$from:$to] (label can't be put inside square brackets in any case)
    2. Generalize chop and chomp with rtrim (see below).
    3. [Edited] Implement similar to head and tail functions called ltrim and rtrim as well as trim which can work with the set of characters like tr, not only integers. or substrings :

      trim(string,tt/leftcharacter_set/, tt/right_character_set/);

      which deleted all characters from the first character set at the left and all characters from the second character set from the right, If only one set is given it uses for trimming both at the left and right

      Similarly ltrim($line,7) is equivalent to substr($line,7) but can be called as subroutine, not only as function. Similarly ltrim($line,'&lth1;) is equivalent to substr($line,max(0,index($line,'<h1')). In case of usage of tr datasets it should operate similar to trim but only on one "side" of the string --left or right.

  6. Allow to specify and use "hyperstrings" -- strings with characters occupying any power of 2 bytes (2,4,8, ...). Unicode is just a special case of hyperstring
    1. $hyper_example1= h4/aaaa/bbbb/cccc/;
    2. $hyper_example2= h2[aa][bb][cc];
    3. $pos=index($hyper_example1,h4/bbbb/cccc/)
  7. Put more attention of managing namespaces.
    1. Allow default read access for global variables, but write mode only with own declaration via special pragma, for example use sunglasses.
    2. Allow to specify set of characters, for which variable acquires my attribute automatically, as well as the default minimum length of non my variables via pragma my (for example, variables with the length of less then three character should always be my)
    3. Allow to specify set of character starting from which variable is considered to be own, for example [A-Z] via pragma own.
  8. Analyze structure of text processing functions in competing scripting languages and implement several enhancements for existing functions. For example:
    1. [Trivial to implement]Allow TO argument in index function, specifying upper range of the search. That can help to exclude unnecessary use of substr to limit the range of search in long strings
    2. [Trivial to implement]Extend the function tr with two new options: E -- exclude, which stops translation at the first symbol which it not in set1 and returns the position of this symbol, and R which can be used with option E to scan string in the reverse direction like rindex. For example, $line=~tr/ \t\n//dER will remove whitespace from the end of the string, while $line=~tr/ \t//dE will remove leading whitespace. Also those new options can be used for searching the position of a symbol in the string more efficiently, for example $pos=$line=~tr/_a-zA-Z//cE will return the position of the first letter in the string.
    3. Implement "delete element" function for arrays.
  9. Improve control statements
    1. [Edited] Eliminate keyword 'given' and treat for(scalar) as a switch statement. Disable smart matching by default. Interpreter should flag as an error if no $_ used in when construct to allow optimization (in this case elsif should be used:
      for($var){ when($_ eq 'b'){ ...;} # means if ($var eq 'b') { ... ; last} when($_ &gt;'c'){...;} } # for
    2. [Questionable] Extend last to accept labels and implement "post loop switch" (See Donald Knuth Structured Programming with go to Statements programming with goto statements)
      my rc==0; for(...){ if (condition1) { $rc=1; last;} elsif(...){$rc=2; last} } if ($rc==0){...} elif($rc==1){...} elif($rc==3){...}

      [Edited]One possible implementation would be usage of Pascal-style local labels (limited to the block in which they are defined), each of which corresponds when in the loop body

      for ...{ when (...); when (...); }after{ default: 1: ... 2: ... }

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

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 or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2021-06-21 13:59 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (98 votes). Check out past polls.