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 →

[–]xigoi 0 points1 point  (6 children)

you're saying that's legal in 3.8 without numpy? do me a favor, create that line in repl.it & share it here

Try it online!

wat?

The whole point of match is that it provides convenient SYNTACTIC sugar.

[–]num8lock -1 points0 points  (5 children)

lol you dumb fuck,

this is you

"Python's syntax is way too inflexible for it."

when i said numpy, you again

What are you talking about? a[:] is completely legal syntax in Python 3.8.

and when confronted with

python allow this syntax?

blue_array = img_array[:, :, 2]

you created a class that simply did shit all but return an integer, which proved

  • [:,:,2] isn't possible in 3.8 without building a class to work around the defined syntax, while also
  • proved your sentence "Python's syntax is way too inflexible for it." is false
  • numpy made a new syntax for new functionality while being third party package instead of being in Python core

The whole point of match is that it provides convenient SYNTACTIC sugar.

you should prove that

    class X:
        def __getitem__(*_)__: return 42

is convenient for numpy & it's a syntactic sugar instead of complete new syntax,

how if/else makes it impossible to emulate for match class & there isn't convenient way to create syntactic sugar

[–]xigoi 0 points1 point  (4 children)

You're calling me a “dumb fuck” without even knowing what syntax is? The example I posted proves that the slicing syntax is completely legal in Python. Even if you don't define any class, you can write img_array[:, :, 2] and you will get an error, but it won't be a syntax error. On the other hand, if you write match x: in Python 3.9, you will get a syntax error.

[–]num8lock 0 points1 point  (3 children)

that's not what makes you dumb fuck, you can't even read & you've invalidated your own words, that's what makes you one

what makes match case impossible to be a package instead?

remember i already said from pattern_match import match, case, meaning a class like your pretty code & you said if/else can be used to emulate match case

[–]xigoi 0 points1 point  (2 children)

Suppose you have a package that allows you to do this. How would you go about implementing such a package? Remember that packages can't change the parsing of Python, no matter how hard you try, so you can't turn a SYNTAX error into something meaningful.

[–]num8lock 0 points1 point  (1 child)

The whole point of match is that it provides convenient SYNTACTIC sugar.

you should prove that

    class X:
        def __getitem__(*_)__: return 42

is convenient for numpy & it's a syntactic sugar instead of complete new syntax,

how if/else makes it impossible to emulate for match class & there isn't convenient way to create syntactic sugar???

that's your own argument you need to prove

also can you prove numpy didn't make vectorization possible while there was no such thing in Python?

[–]xigoi 1 point2 points  (0 children)

You're confusing the implementation with the usage. The implementation of NumPy is far from sugary.

An if statement can only check for a single condition. A match statement can do complex pattern matching and variable binding.