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

duplicate dummy variable #162

Open
dyc-emet opened this issue Nov 10, 2018 · 3 comments
Open

duplicate dummy variable #162

dyc-emet opened this issue Nov 10, 2018 · 3 comments

Comments

@dyc-emet
Copy link

Hi,
When using Module, if we have local variables in the returned expression, they are always the same. It seems that Module doesn't create new local variable names each time as it is supposed to. e.g.

symata 1> g(a_, b_) := Module([c], h(a, c) * h(c, b))

symata 1> g(a, b)
Out(1) = h(a,##c#360)*h(##c#360,b)

symata 2> g(a, b) * g(d, e)
Out(2) = h(a,##c#360)*h(d,##c#360)*h(##c#360,b)*h(##c#360,e)

As you can see, the dummy variable c is always replaced by ##c#360 instead of, for example, ##c#360 from calling g(a,b) and ##c#361 from calling g(d,e).

Is this a bug or did I misunderstand something?

p.s. I don't know how to use the name ##c#360 in the following calculation, it seems I have to somehow escape the # but I haven't figured out the correct way...

@jlapeyre
Copy link
Owner

jlapeyre commented Nov 10, 2018

Yes this is a bug. Maybe it's a regression [EDIT: not really]. It should be fixed and a test added.

@jlapeyre
Copy link
Owner

Module-local variables are Cleared rather than replaced by new variables. This must be part of the solution.

@jlapeyre
Copy link
Owner

p.s. I don't know how to use the name ##c#360 in the following calculation, it seems I have to somehow escape the # but I haven't figured out the correct way...

This problem is fixed in #164. But, the more serious problem will take more work.

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

No branches or pull requests

2 participants