UPDATE: else: is a label. my bad.
So I'm learning Python. I always disdained it because no curlies, but once you start doing stuff in it you get used to it. Sort of
But I still use Perl when I want to cobble something up quick. Using multiple languages has it's issues, though. I get confused. Here's one case where Perl seems to be confused, too, at 5.26.1. I installed perlbrew and it still happens at 5.032000 and 5.033001
#!/usr/bin/perl print "Perl version is: $]\n"; use strict; use warnings; if ( 1 ) { warn "there can only be one, and it's in the IF clause\n" } else: # beware that colon!!!! that's Python, not Perl!!! { warn "there can only be one, and it's in the ELSE clause\n" }
produces
Perl version is: 5.026001 there can only be one, and it's in the IF clause there can only be one, and it's in the ELSE clause Perl version is: 5.032000 there can only be one, and it's in the IF clause there can only be one, and it's in the ELSE clause Perl version is: 5.033001 there can only be one, and it's in the IF clause there can only be one, and it's in the ELSE clause
No warnings, no syntax errors, nothing except the (seemingly) impossible behavior
Removing the colon from the else statement restores correct behavior. gvim didn't catch it either - it's syntax highlighting is as if this was perfectly valid.
Is this a bug, or am i being persnickety?
--Bob
All code given here is UNTESTED unless otherwise stated.
In reply to Python gave me a colonic (solved - brainfart) by bobn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |