- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Unspecified wrong behavior with annotations and extractor vals
Thu, 2010-07-15, 10:06
Dear Scalars,
consider the following:
scala> class Test {
| def f1(implicit i: Int) = println(i)
| def f2(implicit s: String) = println(s)
| implicit val(a,b) = (1,"foo")
|
| def testF1 = f1
| def testF2 = f2
| }
defined class Test
scala> val t = new Test
t: Test = Test@4b48f7e0
scala> t.testF1
1
scala> t.testF2
foo
So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:
doing this doesn't yield transient implicit vals:
@transient implicit val(a,b) = (1,"foo")
Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.
I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".
WDYT?
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
consider the following:
scala> class Test {
| def f1(implicit i: Int) = println(i)
| def f2(implicit s: String) = println(s)
| implicit val(a,b) = (1,"foo")
|
| def testF1 = f1
| def testF2 = f2
| }
defined class Test
scala> val t = new Test
t: Test = Test@4b48f7e0
scala> t.testF1
1
scala> t.testF2
foo
So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:
doing this doesn't yield transient implicit vals:
@transient implicit val(a,b) = (1,"foo")
Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.
I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".
WDYT?
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Thu, 2010-07-15, 11:57
#2
Re: Unspecified wrong behavior with annotations and extractor v
Seems like a bug/feature request to me. Certainly You could work around the issue, but it would be ugly.
- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:
- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:
Dear Scalars,
consider the following:
scala> class Test {
| def f1(implicit i: Int) = println(i)
| def f2(implicit s: String) = println(s)
| implicit val(a,b) = (1,"foo")
|
| def testF1 = f1
| def testF2 = f2
| }
defined class Test
scala> val t = new Test
t: Test = Test@4b48f7e0
scala> t.testF1
1
scala> t.testF2
foo
So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:
doing this doesn't yield transient implicit vals:
@transient implicit val(a,b) = (1,"foo")
Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.
I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".
WDYT?
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Thu, 2010-07-15, 21:17
#3
Re: Unspecified wrong behavior with annotations and extractor
So what's the next step? Trac?
On Thu, Jul 15, 2010 at 12:36 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
On Thu, Jul 15, 2010 at 12:36 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
Seems like a bug/feature request to me. Certainly You could work around the issue, but it would be ugly.
- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:
Dear Scalars,
consider the following:
scala> class Test {
| def f1(implicit i: Int) = println(i)
| def f2(implicit s: String) = println(s)
| implicit val(a,b) = (1,"foo")
|
| def testF1 = f1
| def testF2 = f2
| }
defined class Test
scala> val t = new Test
t: Test = Test@4b48f7e0
scala> t.testF1
1
scala> t.testF2
foo
So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:
doing this doesn't yield transient implicit vals:
@transient implicit val(a,b) = (1,"foo")
Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.
I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".
WDYT?
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
Thu, 2010-07-15, 21:17
#4
Re: Unspecified wrong behavior with annotations and extractor
So what's the next step? Trac?
On Thu, Jul 15, 2010 at 12:36 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
On Thu, Jul 15, 2010 at 12:36 PM, Josh Suereth <joshua.suereth@gmail.com> wrote:
Seems like a bug/feature request to me. Certainly You could work around the issue, but it would be ugly.
- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote:
Dear Scalars,
consider the following:
scala> class Test {
| def f1(implicit i: Int) = println(i)
| def f2(implicit s: String) = println(s)
| implicit val(a,b) = (1,"foo")
|
| def testF1 = f1
| def testF2 = f2
| }
defined class Test
scala> val t = new Test
t: Test = Test@4b48f7e0
scala> t.testF1
1
scala> t.testF2
foo
So, clearly you can create implicit vals from the extractor.
Then, needing to serilaze the class in question, I wanted to make the implicit vals transient but lo and behold:
doing this doesn't yield transient implicit vals:
@transient implicit val(a,b) = (1,"foo")
Now, I assume this also applies for the @volatile annotation and possibly even all annotations in this context.
I think we need to specify the behavior, hopefully to work as expected, or at the very least generate an error if it's "unfixable".
WDYT?
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
--
Viktor Klang
| "A complex system that works is invariably
| found to have evolved from a simple system
| that worked." - John Gall
Akka - the Actor Kernel: Akkasource.org
Twttr: twitter.com/viktorklang
- Josh
On Jul 15, 2010, at 5:06 AM, Viktor Klang <viktor.klang@gmail.com> wrote: