The following should be good enough reason for doing so
On Wed, Aug 21, 2013 at 3:42 PM, Mirco Dotta <mirco...@typesafe.com> wrote:The following should be good enough reason for doing soI was a little shocked at how widely this is used:Not just in toy projects, I spotted it in twitter/util.
Rather than deprecating, perhaps we ought to add all the methods (and of course a test case that keeps the complement of methods complete).
-jason--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Rather than deprecating, perhaps we ought to add all the methods (and of course a test case that keeps the complement of methods complete).
On Aug 21, 2013, at 4:42 PM, Jason Zaugg <jza...@gmail.com> wrote:It doesn't seem manageable. It's too easy to forget to add/remove a method, and then we'd be back with the same problem.
Isn't this something that a @Synchronized macro annotation could solve? But even if that would help, macro annotation are not planned for 2.11 (are they?),and this is something I feel should be fixed in time for 2.11.
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Can you really say with confidence that it has no holes depending on how this trait is mixed into the final class? I'd also say it has to go.
trait SecureMap[K, V] extends collection.mutable.Map[K, V] {override def size: Int = {println("I'm safe!")super.size}}val a = new collection.mutable.ListMap[String, String] with SecureMap[String, String]a.size// I'm safe!// res0: Int = 0trait MyExtraSizeMap extends collection.mutable.Map[String, String] {override def size = 42}val b = new collection.mutable.ListMap[String, String] with MyExtraSizeMap with SecureMap[String, String]b.size// I'm safe!//res1: Int = 42val c = new collection.mutable.ListMap[String, String] with SecureMap[String, String] with MyExtraSizeMapc.size//res2: Int = 42trait SecureListMap[K, V] extends collection.mutable.ListMap[K, V] with SecureMap[K, V]val d = new SecureListMap[String, String] with MyExtraSizeMapd.size//res3: Int = 42val e = new SecureListMap[String, String] with MyExtraSizeMap with SecureMap[String, String]e.size//res4: Int = 42
--
Rather than deprecating, perhaps we ought to add all the methods (and of course a test case that keeps the complement of methods complete).It doesn't seem manageable. It's too easy to forget to add/remove a method, and then we'd be back with the same problem.
This is definitely possible. For example, Tom Switzer wrote a macrofor Spire which wraps arbitrary bits of code and adds overflow
checking (either throwing an Exception or returning Option):
import spire.macros.Checked.{checked, option}
def foo(x: Int, y: Int, z: Int) = checked { x * y + z }
So, even beyond just wrapping an entire method, you could easily wrap
any block of code with a macro that would check permissions, access,
etc.
Synchronized maps seem to be necessary, no? So I vote for fixing them rather than deprecating them.
Synchronized maps are necessary;On Thu, Aug 22, 2013 at 12:35 AM, martin odersky <martin....@epfl.ch> wrote:
Synchronized maps seem to be necessary, no? So I vote for fixing them rather than deprecating them.
synchronization via mixin override trait is unnecessary.
I am surprised anyone sees these traits as anything short of broken by design. There's no baby visible in there, it's all bathwater. If you want a synchronized map I can recommend one which doesn't have comments like "TODO: finish writing code" sprinkled around it, and the correctness of which doesn't depend on the ultra-fragile and untested interplay between an arbitrary number of classes.
--
You received this message because you are subscribed to the Google Groups "scala-internals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-interna...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.