Closed lijunsong closed 11 years ago
Problem2 seems to be solved in modules branch, which implements the MetaDict in a new way.
Using the current master:
l = [1,2,3,4]
l1 = l
l1[1] = 13
print(l) => [1,2,3,4]
print(l1) => [1, 13, 3, 4]
since l1 is correctly modified this problem seems to be one of (lack of) aliasing in the assignment l1=l, and not necessarily related to method invocation.
def f(x):
x[1] = 13333
d = {1:33}
f(d)
print(d) => {1: 13333}
this doesn't seem to be a bug.
@amtriathlon I think the assignment has contained the alias:
l = [1,2,3,4]
l1 = l
l[1] = 13
print(l1) => [1,13,3,4]
the store of the l1 is (VPointer 263), correctly pointing the the reference store.
In the current master assign is giving a new location to l1, what version are you using?
2013/2/5 Junsong Li notifications@github.com
@amtriathlon https://github.com/amtriathlon I think the assignment has contained the alias:
l = [1,2,3,4] l1 = l l[1] = 13 print(l1) => [1,13,3,4]
the store of the l1 is (VPointer 263), correctly pointing the the reference store.
— Reply to this email directly or view it on GitHubhttps://github.com/brownplt/lambda-py/issues/41#issuecomment-13133669.
Alejandro.
@amtriathlon in the scope-rewrite branch.
So, if assignment aliasing is working on scope-rewrite and self aliasing is working in master, probably this bug will be solved with the merge, let's see.
On a related note, IMHO MetaDict representation should be changed to an immutable hash since it is the only use of of mutable data left and it may be hiding other aliasing bugs.
Just wait. Since the module branch has changed the Dict implementation, and the new implementation uses the feature of the mutable hash, it really should consider more about it.
On 2013-2-6, at 下午9:27, Alejandro Martinez notifications@github.com wrote:
So, if assignment aliasing is working on scope-rewrite and self aliasing is working in master, probably this bug will be solved with the merge, let's see.
On a related note, IMHO MetaDict representation should be changed to an immutable hash since it is the only use of of mutable data left and it may be hiding other aliasing bugs.
— Reply to this email directly or view it on GitHub.
resolving the aliasing bug may be helpful to help bootstrap the sys module.
aliasing should also be considered in the interpreting CDict.
PS: And I like the ZEN MODE when editing in github:D
Agree, since aliasing is closely related to scope, waiting for the scope-rewrite merge before making other changes seems the best course of action.
My point is: being that we are using immutable representations for most of mutable Python objects (lists, user defined classes, instances of user defined classes), aliasing is essential for almost everything and, IMHO, dict representation should also be made immutable.
OTOH, if mutable representations are allowed, would be a lot easier to have all mutable Python objects represented using mutable data structures and let racket handle aliasing.
PS: I don't, I prefer to have the context visible.
This problem was solved by the new addresses regime, both examples are giving correct results.
I write the mutable aliasing bug here for reference.
Problem1: list mutation
dict aliasing doesn't have problem, but list does.
This problem might be caused by the function's arguments binding.
l1[1] = 13
can be desugared to something like:The value of
(CId 'l1)
is bound toself
inCFunc
in a new-location as local bound, which means, theCAssign
will set the value that maps fromself
's new-location, not thel1
's location.but this function's argument binding doesn't have any problem:
Problem2: pass dict as argument
BUG:
which may not be related to the aliasing.