Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

by ikegami (Pope)
on Sep 14, 2020 at 22:17 UTC ( #11121770=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

Eliminate keyword 'given' and treat for(scalar) as a switch statement.

You can already do that.

Disable smart marching by default.

At this point, when is virtually an alias for if. It's rather pointless.

Interpreter should flag as an error if no $_ used in when construct to allow optimization

eh? How does being force to use $_ add opportunities for optimization?

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

Replies are listed 'Best First'.
Re^2: What esteemed monks think about changes necessary/desirable in Perl 7 outside of OO staff
by likbez (Sexton) on Sep 17, 2020 at 06:11 UTC
    eh? How does being force to use $_ add opportunities for optimization?
    Theoretically the fact that there are several comparisons allows to make comparison to $_ with long strings faster (say more then 64 characters long). If the switch contains several "when" branches with string constants you can pre-compute hash of them and first compare a hash of $_ with hash of the constant and only if hash matches perform full comparison: you need to compute a single hash of $_ for all comparisons. If all "when" branches represent search without meta characters you can pre-compute a table via Knuth-Morris-Pratt for strings search.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2021-06-21 11:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (98 votes). Check out past polls.

    Notices?