-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement recursively_apply
for Record
#1401
Conversation
Codecov Report
|
recursively_apply
for Record
@ioanaif I've tagged you here because I think this is your area of expertise? Here's an initial implementation of However, whilst 3c79afd nearly passes the simple test that I've added, existing code does not (in many places) expect a non-Content argument in On this note, @jpivarski my main concern is what to do about the Rambling about typesAs we've touched on before, It's funny, I am in general not a fan of strict inheritance hierarchies, but I hadn't realised how much nicer structural subtyping is when there are formal mechanisms to check them (e.g. mypy). I think you already raised the goal of implementing mypy support at a future date, so that's something to look forward to working on. My first instinct here is that |
This is my first impression, so take it with that in mind, but I don't think we want Record to look too much like Content. The thing about the Content hierarchy is that any Content subclass can be a As such, the value of getting Record into a It would save that one special case. Implementations of Streamlining is not always a good idea. If we minimize the differences between Content and Record enough, Records might start getting accidentally passed through as Contents in places where we don't want them to be. The symptom of that would be exceptions getting raised downstream of where the actual mistake happens, and those can be hard to trace back. I can say that some of the connection between low-level Record and Content is historical: in C++, some functions could return arrays or scalars, such as It takes so long to write a response that sometimes I'll have a change of heart while writing it. It might be alright for Record to have a The main benefit of Record's |
Ha, this was my first thought too. Then I flip-flopped after looking at v1.
Agreed. It mainly replaces the burden of checking for
as you put in the this paragraph!
I considered this solution earlier, but I wasn't sure whether this conditional skip would be a bad thing. On balance, I think this might be the best solution - the
I'm glad it's not just me. Sometimes I'll write the same answer three or four times before removing half the text in favour of reading the replies! |
This makes it clear that the `apply` is only ever given a `Content` type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! I just wanted to tweak it a bit, and I'll use GitHub's suggested change to do that. If it passes the test with the change, then it will be merged. (I'll turn on the auto-merge.)
Fixes #1400
As per the discussion below,
Record.recursively_apply
is a top-level function that just forwards the_recursively_apply
call to the content.