<vipqualitypost[m>
what is this? is this just not implemented? is `...` something that does something specific in python?
<Wanda[cis]>
it's an abstract property, it doesn't have a real implementation
<Wanda[cis]>
the body will never be executed, since the abstractmethod will step in and raise an exception first
<vipqualitypost[m>
so this just helps python know that it will do something in the future? I see message used later
<vipqualitypost[m>
ah, ok, cool
<Wanda[cis]>
... is just a convenient way to write a body that does nothing
<Wanda[cis]>
and conveys the "contents don't matter" part
<Wanda[cis]>
vipqualitypost[m: the method is redefined by subclasses of that class
<vipqualitypost[m>
yup, that's what I figured but I never saw it before, google did not show much either
<vipqualitypost[m>
thank you!
<tpw_rules>
`...` is technically an object in python, namely the Ellipsis object. i would say it's bad form, the preferred thing would be to write `pass`
<tpw_rules>
you could put `"nothing to see here"` as the body if you like wanted
<whitequark[cis]>
tpw_rules: it's not, this is literally what Ellipsis is for
<whitequark[cis]>
`pass` is for cases where it actually gets executed, `...` is for cases where it does not
<tpw_rules>
what is `pass` for then?
<Wanda[cis]>
it's not what Ellipsis is for!
<tpw_rules>
i've only ever used ellipsis for slicing
<Wanda[cis]>
it's actually one of the few things in python added for the benefit of numpy
<Wanda[cis]>
it's not used in the core language
<Wanda[cis]>
(it's why it's an object — so you can pass it to slicing operators)
<Wanda[cis]>
like come on, if it was for missing code, it'd throw an exception or something when executed
<tpw_rules>
and not be isomorphic to any other value in that context
<whitequark[cis]>
why do python docs recommend using it
<whitequark[cis]>
if it's bad form
<whitequark[cis]>
that doc is very particular about not using `pass`, and is where I learned to do that
<whitequark[cis]>
tpw_rules: should you file a python bug?
<tpw_rules>
that same page uses ... in several other locations for "put your code here"
<tpw_rules>
on an abstract method there's nothing really to put other than `pass` or some arbitrary pure expression (which ... is) so i see the confusion
<whitequark[cis]>
it would take exactly the same amount of space to put `pass` there so putting an ellipsis there is clearly on purpose
<tpw_rules>
though it does say "Unlike Java abstract methods, these abstract methods may have an implementation. This implementation can be called via the super() mechanism from the class that overrides it."
<whitequark[cis]>
which means it's the correct thing to do :3
<tpw_rules>
so `...` does still have the same meaning in your screenshot of arbitrary user code, strange though it may be
<whitequark[cis]>
(I'll continue using and teaching `...` in that position until the doc is fixed)
<tpw_rules>
amaranth currently chooses `raise NotImplementedError`, a docstring, `pass`. nowhere does it have `...`
<tpw_rules>
i'm not sure it's valid to change that doc to have `pass` because of the note that it can have a concrete implementation
<tpw_rules>
it also seems others share your view and PEP8 has no word on the topic
<Wanda[cis]>
I should note that while ellipsis was added for numpy, it has since become used for "body is meaningless" contexts.
<Wanda[cis]>
PEP 484 explicitly says ... should be used as function body in typing interface files
<Wanda[cis]>
so there's some precedent
<tpw_rules>
some say `pass` is for "never should have an impl" and `...` is for "need to get around to the impl"
<Wanda[cis]>
no.
<Wanda[cis]>
pass is for "empty impl"
<Wanda[cis]>
like, it's valid to have a function that does nothing!
<tpw_rules>
sorry, yeah. "i don't intend an impl"
<tpw_rules>
`raise NotImplementedError` is closer to never should have one
<Wanda[cis]>
but also: I agree that Python documentation makes this unclear
<whitequark[cis]>
<tpw_rules> "amaranth currently chooses `..." <- there should be a few in the typing overloads in the simulator
<tpw_rules>
there seems more in alignment as it's a typing thing
<tpw_rules>
you are probably right that python's docs need fixing. Wanda[cis] have you worked with python upstream at all? are you interested in tracking it down
<Wanda[cis]>
I have not
<tpw_rules>
me neither
Degi_ has joined #amaranth-lang
<Wanda[cis]>
(or I think I did not? living with major memory loss sure is fun)
Degi has quit [Ping timeout: 268 seconds]
Degi_ is now known as Degi
sohaiber[m] has joined #amaranth-lang
<sohaiber[m]>
It would be nice to iterate over Signal(ArrayLayout), currently View.__getitem__ doesnt raise IndexError, is this intended?
<Wanda[cis]>
hm?
<Wanda[cis]>
oh.
<Wanda[cis]>
# Layout's interface requires us to raise KeyError, not IndexError yeah it is... intended
<Wanda[cis]>
this sure looks like unintended consequences though
<sohaiber[m]>
oh just saw that because View.getitem just uses word_select in the case of ArrayLayout
<sohaiber[m]>
guess what i want can also be easily done with Signal(width*length) and word_select
<whitequark[cis]>
<Wanda[cis]> "# Layout's interface requires..." <- we... could potentially raise KeyError for strings and IndexError for ints
<whitequark[cis]>
this is fairly cursed but I don't necessarily see why we shouldn't do it
<Wanda[cis]>
mhm
<Wanda[cis]>
either that or just implement __iter__ manually
<whitequark[cis]>
I think I'd prefer KeyError/IndexError since it matches the underlying intent
<Wanda[cis]>
Catherine: I can just implement it, which one do you hate less?
<whitequark[cis]>
(of implementing a sort of a hybrid interface)
<_whitenotifier-f>
[amaranth-lang/amaranth-lang.github.io] github-merge-queue[bot] 2bbf76b - Deploying to main from @ amaranth-lang/amaranth@cd679dd9b3e969ba385ee2833f4b90f7343d60bf 🚀
frgo has quit [Read error: Connection reset by peer]
frgo has joined #amaranth-lang
bl0x[m] has quit [Quit: Idle timeout reached: 172800s]
mcc111[m] has quit [Quit: Idle timeout reached: 172800s]