Comments (8)
I understand the relationship with #1 and the issue of the additional object being added to the pickle.
However, I don't understand how you're getting this behavior: X.b(0) == 4
?
As far as I can see, it has to be X.b(0) == 1
.
Example:
import scala.pickling._
import json._
object Main extends App {
class X {
var a = List(1,2,3)
var b = a
}
val x = new X
println(x.b(0))
val p = x.pickle
println(p.value)
val u = p.unpickle[X]
println(u.b(0))
}
Correctly Results in:
1
{
"tpe": "Main.X",
"a": {
"tpe": "scala.collection.immutable.$colon$colon[scala.Int]",
"elems": [
1,
2,
3
]
},
"b": {
"tpe": "scala.collection.immutable.$colon$colon[scala.Int]",
"elems": [
1,
2,
3
]
}
}
1
That is b(0) is 1, not 4. Did I miss something? I'd just like to ensure something isn't semantically amiss with the pickle format.
from pickling.
It also seems that in the pickle you pasted into the issue description, you might have an array, not a list? Our JSONPickled output looks a bit different...
Even if I change X
's fields to be an array instead of a list, I still get the correct expected output:
1
{
"tpe": "Main.X",
"a": [
1,
2,
3
],
"b": [
1,
2,
3
]
}
1
from pickling.
Yeah, I meant an array. The output contains the correct values, but the serialization should have some way of indicating that a and b are references to the same object, so that you don't get slightly different data when you serialize classes like these.
from pickling.
Yep, as mentioned I understand that– though you earlier mentioned some additional semantically incorrect behavior X.b(0) = 4. The issue description has since been edited, so I take it that all is OK, semantically, with accessing the 0th element of an unpickled instance of member b
of X
? That is, that point is a non-issue, right?
Good thing is that, as mentioned in related ticket #1, we're currently working to make pickling cyclic object graphs possible and more convenient– so both #1 and #2 should be resolved once our fix is pushed. :-)
from pickling.
Yep, as mentioned I understand that– though you earlier mentioned some additional semantically incorrect behavior X.b(0) = 4.
Yeah I meant to say what I'm now showing with the example code. Sorry I wasn't clear. Thanks a lot 👍
from pickling.
Ah, yeah totally missed that the example code changed too! Sorry! Alright, awesome, all clear now, thanks! :)
from pickling.
As commented on #1, this has been resolved in the "oopsla2013" branch (https://github.com/scala/pickling/tree/oopsla2013) and will be integrated into the main branches soon.
from pickling.
All of this is now in the main 2.10.x branch, so marking as fixed :)
from pickling.
Related Issues (20)
- Improve performance of implicit search HOT 3
- StaticOnly should be enabled by default HOT 2
- Refined types should be supported HOT 1
- Cut first milestone release HOT 13
- Add picklers and unpickler for Nothing HOT 1
- Variadic arguments for case class HOT 4
- Remove patmat warnings HOT 1
- Can't unpickle ValueSet HOT 2
- Pickling 0.10.2-SNAPSHOT for Scala 2.10
- Compile time serialisation failing for nested case classes with Scala 2.10.6 HOT 2
- Error when saving a Map of Int and a Composite
- java.lang.VerifyError: Bad type on operand stack while encapsulating Pickler
- Some macro in PicklerUnpickler is not serializable
- Deserialization in incorrect type
- Consider dropping or updating the link to http://lampwww.epfl.ch/~hmiller/pickling
- Unpickle without specifying type HOT 1
- Is this project abandoned? HOT 14
- Incorrect handling of Option[xxx] if None HOT 13
- val from trait not pickled
- Pickling fails with a weird issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pickling.