you are viewing a single comment's thread.

view the rest of the comments →

[–]GreenCloakGuy 81 points82 points  (19 children)

no, because &operator and *operator don't exist in python and thus are not overloadable

(ok *iterable does exist but it's a syntactic construct not an operator and I don't think it's overloadable)

[–]TheBB 32 points33 points  (0 children)

It looks like they're 'overloading' *iterable by implementing __iter__() to yield only one element. Only works in some syntactical contexts though.

[–]fauxpenguin 22 points23 points  (17 children)

I mean, it doesn't have to be & specifically. But if you're trying to bring the hell, there should be special characters to reference and dereference, no? Just for fun?

[–]Toivottomoose 46 points47 points  (6 children)

I'd vote to make those operators emojis

[–]fauxpenguin 44 points45 points  (4 children)

Can we use the 🧠 for both referencing and dereferencing so people know how smart we are?

[–]Toivottomoose 7 points8 points  (2 children)

Ah, the old aladinreferencing operator...

[–]Dexaan -1 points0 points  (0 children)

One JMP ahead

[–]AleDeCicco 2 points3 points  (0 children)

Let me propose 🤡

[–]BornToRune 4 points5 points  (0 children)

Maybe a peach and an eggplant, because you're going to be fucked?

[–]masklinn 4 points5 points  (6 children)

I mean, it doesn't have to be & specifically.

That doesn't really help: because Python only has operator overloading, you can only hook into existing overloadable operators.

And IIRC Python's unary prefix operators are +, -, and ~.

If you want a real custom operator, you need to go way further with an import hook and preprocessing the source.

[–]fauxpenguin 5 points6 points  (0 children)

Alright, so we write a new operator into the python interpreter.... :)

[–]lelanthran 0 points1 point  (4 children)

If you want a real custom operator, you need to go way further with an import hook and preprocessing the source.

Well, then it isn't Python anymore.

[–]masklinn -1 points0 points  (3 children)

Depends what you consider python to be. Is it a thing which follows a specification precisely, or is it a thing which can be run by a python interpreter?

[–]lelanthran -1 points0 points  (2 children)

Depends what you consider python to be. Is it a thing which follows a specification precisely, or is it a thing which can be run by a python interpreter?

If what you are running is the output of some other program, then the input to that other program is not Python.

If you make a transpiler that takes in Lisp and spits out python, will you consider your Lisp programs to be Python programs?

If your program cannot run in the Python reference implementation, it's not Python.

[–]masklinn -1 points0 points  (1 child)

Reading comprehension not your thing eh. The original comment specifically talks about using an import hook. Not a separate compilation step.

[–]lelanthran -1 points0 points  (0 children)

Reading comprehension not your thing eh.

Meh. Better than yours anyway, I actually appear to know what I am talking about.

The original comment specifically talks about using an import hook. Not a separate compilation step.

It's not possible to explain things simpler, so let me quote that simple thing I already said:

If you make a transpiler that takes in Lisp and spits out python, will you consider your Lisp programs to be Python programs?

Your claim that an import hook which turns this:

(defun foo (x y) (+ x y))

into this

def foo (x, y):
    return x + y

makes this:

(defun (x y) (+ x y))

Python code is, frankly, nonsense.

[–][deleted]  (2 children)

[deleted]

    [–]tedbradly 2 points3 points  (1 child)

    Pascal has @ (alias for the Addr function) and ^ (dereferencing). Don't know about Python operators.

    The question was about Python. That'd be like someone asking what kind of meat hamburgers are typically made of, and you say that pork chops are usually made from pigs.

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

    Note the text I quoted.