Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Why Perl is better than Python

Name: Anonymous 2012-06-02 13:53


typo = 0;
while (typo < 10): # timeout
  typ0 = typo + 1


Compared to:


use strict;
my $typo = 0;
while ($typo < 10) {
  $typ0 = $typo + 1 # will abort with error
}

Name: Anonymous 2012-06-02 14:24

local function nope (_, k) error("undeclared `" .. k .. "'", 2) end
setmetatable(getfenv(1), { __index = nope, __newindex = nope })

local typo = 0
while typo < 10 do
  typ0 = typo + 1
end

>local by default
>typos turn into new variables

>global by default
>catch all global assignments

like a boss

Name: Anonymous 2012-06-02 14:33

>>1
Why do you have to ``use strict'', is Perl that shit?

Name: Anonymous 2012-06-02 14:47

>>3
Because he neglected to mention that if he doesn't, perl has the exact same semantics as python in that case

Name: Anonymous 2012-06-02 15:06

>>4
Yeah, but in your toy language there is no "use strict" counterpart...

Name: Anonymous 2012-06-02 15:19

>>5
My toy language is Haskell.

Name: Anonymous 2012-06-02 16:50

>>6
U MENA HASKAL

Name: Bernd 2012-06-02 17:03


#!/usr/bin/env ruby

typo = 0
while typo < 10 do
    typo = typo + 1
end

Name: Anonymous 2012-06-02 18:24

Haskell version:

module Main where

main = wh
Segmentation fault: Haskell can't do loops or variables!

Name: Anonymous 2012-06-02 18:38

>>7
Umena MY LOVE

Name: Anonymous 2012-06-02 19:42

enjoy your concept of 0 but true and your pathological language that cannot be unambiguously parsed


module EatMe where
  main = do
    typo <- newIORef 0
    [0..9] `forM_` const (modifyIORef typo (+1))

Name: Anonymous 2012-06-03 1:40

>>3
>>4
IMO "use strict;" should be the default, and you should have to actively decline the use of strict. More people would use strict that way.

All good perl programs start with "use strict;".

Name: Anonymous 2012-06-03 1:51


(do ((typo 0))
    ((> typo 10))
  (incf typ0))
UNDEFINED VARIABLE:
 type0

Name: Anonymous 2012-06-03 2:50

>>3
>>12
To be fair, it is not exactly required. It's not going to break your script if you omit it. It's more of a tool to keep you from writing shitty code. In that case, I agree with you that it should be on by default.

YEAH, BUT WHO DOESN'T use strict; THEIR CODE?

Name: Anonymous 2012-06-03 2:55

>>13
At least the python interpreter doesn't give errors about variables you've never even talked about in your code.

Name: Anonymous 2012-06-05 16:38

>>1


typo = 0

while typo < 10:
  typ0 += 1 # NameError


Now go away.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List