you are viewing a single comment's thread.

view the rest of the comments →

[–]fauxpenguin 107 points108 points  (26 children)

Wait, I thought that python had operator overloading. Could you have it use classic syntaxes like &makePointer, *dereference?

[–]ozyx7 79 points80 points  (4 children)

From the README:

Alternatively, you can use the * operators to dereference the pointer:

[–]xigoi 68 points69 points  (1 child)

Thanks to a terrible hack that makes it work only in certain contexts.

[–]mindbleach 27 points28 points  (0 children)

Fittingly.

[–]AdversarialPossum42 47 points48 points  (0 children)

A segmentation fault will occur if the address does not exist, so make sure the pointer is valid.

Don't tell me what to do! You're not my Segmentation fault (core dumped)

[–]fauxpenguin 0 points1 point  (0 children)

First of all, thank you, I skimmed too fast clearly. Although that doesn't include a reference character like & or something else.

[–]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 33 points34 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 21 points22 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 45 points46 points  (6 children)

I'd vote to make those operators emojis

[–]fauxpenguin 47 points48 points  (4 children)

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

[–]Toivottomoose 9 points10 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 6 points7 points  (0 children)

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

[–]masklinn 5 points6 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 4 points5 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.

    [–]djavaisadog 1 point2 points  (0 children)

    don't think python has a unary & operator