rapydscript-ng icon indicating copy to clipboard operation
rapydscript-ng copied to clipboard

Ellipsis

Open jayvdb opened this issue 3 years ago • 7 comments

rapydscript-ng appears to have no support for ellipsis (...).

It seems like simply treating this as pass would be sufficient for most case, as its other use as a complex slicer e.g. in numpy, is unlikely to work in rapydscript for other reasons.

jayvdb avatar May 29 '21 06:05 jayvdb

I prefer syntax errors, which are easy to detect and fix at compile time, over runtime behavior that may or may not do what is expected.

kovidgoyal avatar May 29 '21 06:05 kovidgoyal

Well it is easy enough to detect when ... is used as a statement instead of part of a subscript or other expression construct.

jayvdb avatar May 29 '21 06:05 jayvdb

... is not a statement in python, its an expression that expression that evaluates to the Ellipsis object, just like None evaluates to the None object.

kovidgoyal avatar May 29 '21 06:05 kovidgoyal

I meant it can be detected when the Ellipsis object is the only part of the statement, meaning it can be ignored, so that there is no ambiguous behaviour. Anyways, this isnt a major problem for me as I can easily remove them in a python ast rewrite phase before I invoking rapydscript.

jayvdb avatar May 29 '21 07:05 jayvdb

Ah, I see, yes that's true. But why? Why allow ellipsis in one context and not in lots of others? Seems fairly arbitrary.

kovidgoyal avatar May 29 '21 07:05 kovidgoyal

Unlike statement pass, ... is a more versatile placeholder, so it is frequently used to indicate "not implemented" in a visually appealing way.

def foo(a, b):
    c = a + 1
    ...  # Need to do blah blah
    return c + b

It is a bit arbitrary, but it seems like an easy win for people who use it in that way.

jayvdb avatar May 29 '21 08:05 jayvdb

OK, I can see some value in doing that. Not something I am particularly keen on since the only place I have ever seen/used ... as a statement is pyi files, but I will accept a patch for it.

kovidgoyal avatar May 29 '21 08:05 kovidgoyal