←back to thread

2024 points randlet | 1 comments | | HN request time: 0.218s | source
Show context
sametmax ◴[] No.17516409[source]
It's going to be very interesting to see if things like:

- pattern matching

- inline exception catching

- path inclusion in the built in

- more functional tooling

- lazy keywors

That were BDFL-blocked, will go back to be debated in the mailing list in the next months.

And if yes, will the community stands by its root or create a new era ?

The consequences of which we will only really see in 10 years.

Guido as done an incredible job at being the boogie man, keeping the language simple and readable. It's a hard job.

Can we pull it off ?

replies(4): >>17516765 #>>17518674 #>>17519896 #>>17519907 #
bluecalm ◴[] No.17516765[source]
I think he made a right call blocking all of those. There are Pythonic ways to do all of those already and the mantra there should be one and preferably one way of doing things is important for the philosophy of the language.

With PEP 572 it wasn't like that. There wasn't a Pythonic way to do list comprehensions which used the same expensive to evaluate expression two times in it and it was I think the only glaring syntax weakness in comparison to languages which have a way to do that (like WHERE keyword in Haskell).

replies(4): >>17517691 #>>17517949 #>>17518030 #>>17518364 #
rthomas6 ◴[] No.17517691[source]
What's the Pythonic way of pattern matching?
replies(2): >>17517721 #>>17517956 #
owaislone ◴[] No.17517956[source]
A dictionary of string: functions I guess? Don't think there is a decent one
replies(1): >>17518172 #
marcosdumay ◴[] No.17518172[source]
That's parametrized jumping. Pattern matching is parsing a structure with variables and filling those variables from a single structured value.

Python does that with tuples:

    a, b = b, a
But it just stops there. To be fair, I don't know how much power it would gain by going further either. Never made that question.
replies(1): >>17518289 #
joshuamorton ◴[] No.17518289[source]
That is more commonly known as destructuring. (in python and javascript at least, as well as a few others iirc)

Pattern matching is normally (in functional languages like Scala and Haskell anyway) defined as a way of taking a union type and handling each one safely. It's a sort of functional alternative to polymorphism.

That is, polymorphic code

    class Dog(Animal):
        def make_noise(self):
            return "bork bork"

    class Duck(Animal):
        def make_noise(self):
            return "quack"
would, with pattern matching be (in pseudo haskell I hope)

    make_noise :: Animal -> str
    make_noise Duck = "quack"
    make_noise Dog = "bork bork"
In other words, in an oop style you delegate to the object that it implements all methods. Whereas with pattern matching you can have a type delegate to each of the functions that can operate on it to handle it correctly. (This explanation is a disservice to functional styles, its a lot more elegant than what I describe if you do it correctly).
replies(2): >>17519064 #>>17520332 #
1. ◴[] No.17519064[source]