(import
contextlib [nullcontext])
(with [a (nullcontext) b (do a (nullcontext))])
This raises NameError: name 'a' is not defined. How this happens is clear enough to the experienced Hy programmer, but that it happens at all can be surprising considering that e.g.
(for [a [1] b (do a [1])])
works fine. And the Python language reference specifies that
With more than one item, the context managers are processed as if multiple with statements were nested:
with A() as a, B() as b:
SUITE
is semantically equivalent to:
with A() as a:
with B() as b:
SUITE
So it's surprising that this equivalency doesn't hold for Hy.
Consider:
This raises
NameError: name 'a' is not defined
. How this happens is clear enough to the experienced Hy programmer, but that it happens at all can be surprising considering that e.g.works fine. And the Python language reference specifies that
So it's surprising that this equivalency doesn't hold for Hy.