For me the problem with the dominate example is not so much the extra with
keywords, but the magic action at a distance for what looks like regular function calls (e.g. in the first with
link(...)
not only creates a link object, but also adds it to doc.head
. As with so much new functionality that’s something we could get use to, but right now it feels wrong.
Not to pick on the dominate example, but it introduces spooky action at a distance, the following code adds li
items to the ol
without any visible connection between the two. That’s not good for understandably and maintainability of code.
def magic():
for i in ['home', 'about', 'contact']:
li(a(i.title(), href='/%s.html' % i))
with doc:
with div(id='header').add(ol()):
magic()
Your proposal doesn’t have this particular problem, but there’s still a lot of opportunities to introduce unexpected behaviour in your proposal, including side effects of regular refactoring (e.g. splitting of a calculation that’s getting too complex introduces new variables and that affects what’s getting passed to __trailing__
. SwiftUI appears to get away with this, but they have static typing at compile time and did have serious usability problems when the feature was first introduced (in particular hard to understand compiler errors when you made a mistake).