- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Re: tuples and specialization - surprise
Wed, 2012-01-18, 21:39
i kinda expected tuple2specialized to be:
class Tuple2Double(val a:double, val b:double)
not
class Tuple2Double(val a:double, val b:double, val unused1:Object, val unused2:Object)
Am 18.01.2012 21:33, schrieb √iktor Ҡlang:
class Tuple2Double(val a:double, val b:double)
not
class Tuple2Double(val a:double, val b:double, val unused1:Object, val unused2:Object)
Am 18.01.2012 21:33, schrieb √iktor Ҡlang:
2mkdimOiDPaW-JwnHt7jh_CO1OPNA [at] mail [dot] gmail [dot] com" type="cite">
On Wed, Jan 18, 2012 at 9:29 PM, HamsterofDeath <h-star [at] gmx [dot] de" rel="nofollow">h-star@gmx.de> wrote:
why are there 4 members instead of 2?
How else do you store a primitive without boxing it?
--
Viktor Klang
Akka Tech Lead Typesafe - The software stack for applications that scale
Twitter: @viktorklang
Sat, 2012-01-21, 17:21
#2
Re: tuples and specialization - surprise
On 18 January 2012 23:04, Rex Kerr <ichoran@gmail.com> wrote:
Tuple2 is a class from which Tuple2$mcDD$sp inherits.
Therefore, unfortunately, it inherits the now-unused fields _1 and _2 (and the extra 8 bytes of storage that those require).
A scheme where there was a common base class that has no fields (just accessors) and the object-containing fields were in the (default) subclass would avoid this problem (albeit at the cost of confusing all the class names even when the specialized version wasn't used).
Right, so if a class is specialized, perhaps this should cause specific sub-classes to be generated for the Any cases in addition to the primitive ones? Who knows, it may even clean up some of the implementation ;)
Matthew
--Rex
2012/1/18 HamsterofDeath <h-star@gmx.de>i kinda expected tuple2specialized to be:
class Tuple2Double(val a:double, val b:double)
not
class Tuple2Double(val a:double, val b:double, val unused1:Object, val unused2:Object)
Am 18.01.2012 21:33, schrieb √iktor Ҡlang:
On Wed, Jan 18, 2012 at 9:29 PM, HamsterofDeath <h-star@gmx.de> wrote:
why are there 4 members instead of 2?
How else do you store a primitive without boxing it?
--
Viktor Klang
Akka Tech Lead Typesafe - The software stack for applications that scale
Twitter: @viktorklang
--
Dr Matthew PocockIntegrative Bioinformatics Group, School of Computing Science, Newcastle Universitymailto: turingatemyhamster@gmail.com gchat: turingatemyhamster@gmail.commsn: matthew_pocock@yahoo.co.uk irc.freenode.net: drdozerskype: matthew.pococktel: (0191) 2566550mob: +447535664143
Therefore, unfortunately, it inherits the now-unused fields _1 and _2 (and the extra 8 bytes of storage that those require).
A scheme where there was a common base class that has no fields (just accessors) and the object-containing fields were in the (default) subclass would avoid this problem (albeit at the cost of confusing all the class names even when the specialized version wasn't used).
--Rex
2012/1/18 HamsterofDeath <h-star@gmx.de>