-
Notifications
You must be signed in to change notification settings - Fork 67
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
Quantification expressions should have their own name scope #10
Comments
Right, but note that the former is bad too, and Python 3 does not do that.
That's my point last Thursday---it's independent of whether there is an
implicit "self".
For example:
>> [i for i in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>> i
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'i' is not defined
>> i = 0
>> [i for i in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>> i
0
…On Sun, Jun 25, 2017 at 11:36 AM, Bo Lin ***@***.***> wrote:
Currently, a quantification expression does not introduce a name scope,
which means any variables bound by the expression is "pass through" to the
parent scope. The original consideration was to simplify witness binding.
For example,
class P(process):
def setup():
self.n = 1
def run():
some(n in [1, 2], q in [2, 3])
output(n, q)
the existential quantification in P.run() will bind q in the local scope
of run, but will also bind the process-level `n``. The latter behavior
which would be counter-intuitive, and runs contrary to Python's binding
rules for comprehensions.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#10>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AIb1-aozUVJerIlGXuW0r3XGWIzPXo9xks5sHn52gaJpZM4OEo4x>
.
|
But the former is DistAlgo's witness binding semantics for existential quantifications. |
Back to this: indeed, we had decided that the scope for "some" is the So there are two ways to interpret your example:
In a richer language with block scopes, "some" could have smaller however, in general, nested local scopes need more effort to in the special case of "some", it could be worthwhile to add, and so for now at least, the current implementation for Python is ok. |
Currently, a quantification expression does not introduce a name scope, which means any variables bound by the expression is "pass through" to the parent scope. The original consideration was to simplify witness binding. For example,
the existential quantification in
P.run()
will bindq
in the local scope ofrun
, but will also bind the process-level `n``. The latter behavior which would be counter-intuitive, and runs contrary to Python's binding rules for comprehensions.The text was updated successfully, but these errors were encountered: