-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
usingmodule()! Who would have guessed!
- Loading branch information
1 parent
e5101d2
commit 16f5086
Showing
1 changed file
with
8 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16f5086
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.
Oh dear. I wish
usingmodule
didn't have to exist.16f5086
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.
Is this a syntax parsing issue? I must admit, I was a little surprised by this
16f5086
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.
It was based on a PR that sat for many months, and only ever got upvotes. So eventually I decided to pull the trigger.
16f5086
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.
Ah, is this because
using
inside anif
statement would be evaluated in the scope of the if block? I guess I'm still not sure why ausing
directive in nested scope would throw an error, though.....16f5086
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.
Originally I wanted
using
to be a more static thing, making it easier to deal with cases like #3648 . But since this workaround exists anyway, there's no point, and I might as well allowusing
inside anif
. I guess it is ok as long as theusing
happens at load time, since we can't change global bindings arbitrarily after that point.16f5086
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.
So what happens if someone tries to do exactly that? e.g. uses the
usingmodule()
trick in the middle of running some huge piece of code?16f5086
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.
It's not a disaster, but (1) it affects the dynamically current module (likely
Main
) rather than the module the call appears in, which is probably not what you want, and (2) it's not clear which bindings will be affected, since most global variables you're using will probably be resolved already, but perhaps not all, and those remaining ones could resovle differently as a result of theusingmodule
.16f5086
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.
I see. Is this roughly the same problem as #265, only generalized beyond functions to just generic symbols? (I suppose I'm assuming
resolve(symbol) ~== compile(function)
)16f5086
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.
Yes, it is similar, but not as serious since we simply don't allow changing how global bindings resolve, while we do allow changing method tables.