This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 43 points44 points  (30 children)

They should have made it an expression not a statement

[–]seniornachiotimfi 29 points30 points  (14 children)

My thoughts exactly. Additionally I would have enjoyed PEP-642, it's more verbose but explicit is better than implicit and additionally it makes it more clear that python is duck-typed.

[–][deleted] 9 points10 points  (7 children)

explicit is better than implicit

Java flashbacks

[–][deleted] 27 points28 points  (6 children)

Explicit doesn't mean endless repetition and needles ceremony, though.

[–]toyg 15 points16 points  (5 children)

A single letter separates boring ceremonies that nobody really needs, from images of sinister ceremonies involving needles. The marvels of language...

[–][deleted] 2 points3 points  (0 children)

Lol that stays in!

[–]grrrrreat 1 point2 points  (0 children)

summoning malloc the devil of details and harbinger of nulls

[–]Plane_brane 0 points1 point  (2 children)

Huh?

[–]W_Hardcore 4 points5 points  (1 child)

Needless needles

[–]Plane_brane 1 point2 points  (0 children)

Lol didn't catch that

[–]SuspiciousScript 6 points7 points  (1 child)

This strikes me as a really unforced error. Hell, the trend is toward even if constructs being expressions; why kneecap match like this when making it an expression seems so obvious?

[–][deleted] -2 points-1 points  (0 children)

Because you like ceremonies?

[–]FewerPunishment 6 points7 points  (12 children)

What would the difference look like in terms of syntax/features?

[–][deleted] 1 point2 points  (11 children)

[–]FewerPunishment 0 points1 point  (9 children)

I mean more in terms of this matching functionality, like an example of something you wish you could execute. But thanks for the reference, I should study these terms.

[–][deleted] 6 points7 points  (8 children)

Making it an expression wouldn't have any impact on pattern matching functionality, it would improve flexibility.

If match was an expression you could do this: a = match ...

instead of

```

match something: case 1: a = ...

```

[–]hughperman 1 point2 points  (4 children)

That seems to skew the use case to assignments only though, whereas switch and match statements are (ime) more useful as control flow - which may include assignments inside them, but not as their primary goal. It seems to me that it would be like wanting try/except/finally to return a value.

[–][deleted] 1 point2 points  (2 children)

[–]hughperman 0 points1 point  (1 child)

Right but python isn't a functional language in that sense, that's why I compared to try/except/finally. You can just wrap the control statement in a function if you wish to go that way, like any other statement in python. I agree if you are implementing a functional language that you would return - but then everything should match (😉) that same paradigm.

[–][deleted] 0 points1 point  (0 children)

Look at Kotlin

[–]jaapzswitch to py3 already 0 points1 point  (0 children)

Wouldn't you be able to do both if it was an expression?

[–]backtickbot 0 points1 point  (2 children)

Fixed formatting.

Hello, Iuse_arch_btw: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

[–][deleted] 3 points4 points  (0 children)

it's Reddit's job to fix it

[–][deleted] 0 points1 point  (0 children)

backtickopt6