Skip to content
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

Support dynamic generation of the interactive namespace in rc.elv #613

Closed
xiaq opened this issue Mar 1, 2018 · 1 comment
Closed

Support dynamic generation of the interactive namespace in rc.elv #613

xiaq opened this issue Mar 1, 2018 · 1 comment

Comments

@xiaq
Copy link
Member

@xiaq xiaq commented Mar 1, 2018

Right now rc.elv runs in the same namespace as the namespace the interactive session runs in (the "interactive namespace"). That makes it difficult to do some things like generating aliases, before namespaces in Elvish are very much static. This is how we can address that:

If rc.elv contains a special variable called, say $-exports-, its content is poured into the interactive namespace after rc.elv finishes running. For example if rc.elv contains:

-exports- = [&]
range 10 | each [x]{ -exports-[$x] = $x }

Then in the interactive session you have variables $0 through $9.

The names defined in $-exports- are brought into the interactive namespace in addition to the rc.elv namespace itself, with the latter taking precedence in case of a conflict. For instance if rc.elv contains

x = foo
y = bar
-exports- = [&x=foo2 z=lorem]

Then in the interactive namespace, you have x=foo, y=bar and z=lorem.

@xiaq xiaq added the enhancement label Mar 1, 2018
@xiaq xiaq added this to the 0.12 milestone Mar 1, 2018
@xiaq xiaq closed this in 4d252db Mar 1, 2018
@zzamboni
Copy link
Contributor

@zzamboni zzamboni commented Mar 2, 2018

I have updated https://github.com/zzamboni/elvish-modules/blob/master/alias.org to work with this new implementation of -exports-.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.