l**********n 发帖数: 8443 | 1 is a code block like { } a Callable? |
c******o 发帖数: 1277 | 2 you mean anonymous function?
Which is just a function and NOT java.util.concurrent.Callable
you can use implicit conversion to automatically do it though.
http://qerub.se/scala-runnable-and-callable |
l**********n 发帖数: 8443 | 3 thanks.
【在 c******o 的大作中提到】 : you mean anonymous function? : Which is just a function and NOT java.util.concurrent.Callable : you can use implicit conversion to automatically do it though. : http://qerub.se/scala-runnable-and-callable
|
l**********n 发帖数: 8443 | 4 scala的implicit type conversion很变态啊。完全是违反static typing的原则啊。 |
l**********n 发帖数: 8443 | 5 下面的代码是不是很变态:
case class Alcohol(liters: Double)
case class Water(liters: Double)
case class Fire(heat: Double)
trait Flammable[A] {
def burn(fuel: A): Fire
}
implicit object AlcoholIsFlammable extends Flammable[Alcohol] {
def burn(fuel: Alcohol) = Fire(120.0)
}
def setFire[T] (fuel: T) (implicit f: Flammable[T] ) = f.burn (fuel)
setFire (Alcohol (1.0) ) // ok
setFire(Water(1.0)) // FAIL -
// See more at: http://www.azavea.com/blogs/labs/2011/06/scalas-numeric-type-class-pt-1/#sthash.2A2Wo4uH.dpuf |
l**********n 发帖数: 8443 | |
c******o 发帖数: 1277 | 7 http://www.scala-lang.org/api/current/#scala.languageFeature$
All the things list in this package are dangerous, but can be amazing. (
which require you to import the flag package to use it) |
l**********n 发帖数: 8443 | 8 读scala代码简直是摧残啊。
比如这个:
/**
* Sort so that subtypes always precede their supertypes, but without
* obeying any order between unrelated subtypes (insert sort).
*/
private def sort(in: Iterable[ClassSerializer]): immutable.Seq[
ClassSerializer] =
((new ArrayBuffer[ClassSerializer](in.size) /: in) {
(buf, ca) ⇒
buf.indexWhere(_._1 isAssignableFrom ca._1) match {
case -1 ⇒ buf append ca
case x ⇒ buf insert(x, ca)
}
buf
}).to[immutable.Seq] |
l**********n 发帖数: 8443 | 9 Scala的这种东西真多:
if (message ne null) Left(message) else Option(pattern) map (new Regex(_))
toRight start |
l**********n 发帖数: 8443 | |
|
|
c******o 发帖数: 1277 | 11 follow the type, and it is easy, just follow the type.
Same thing written in Clojure is even more difficult. |
q*c 发帖数: 9453 | 12 scala 的发明者和拥护基本都是左派,自我中心,自私自利和愚蠢短视的人群代表。
【在 l**********n 的大作中提到】 : 这样的代码读起来很爽吗!!!
|
c******o 发帖数: 1277 | 13 Oh, come on, if you can not do it, do not do it. Cursing does not solve
anything.
Leave it to the people who can do it.
BTW, I do not use those DSL at all. Only literal functions.
【在 q*c 的大作中提到】 : scala 的发明者和拥护基本都是左派,自我中心,自私自利和愚蠢短视的人群代表。
|
g*****g 发帖数: 34805 | 14 He hates the language, not the money.
【在 c******o 的大作中提到】 : Oh, come on, if you can not do it, do not do it. Cursing does not solve : anything. : Leave it to the people who can do it. : BTW, I do not use those DSL at all. Only literal functions.
|
z*******3 发帖数: 13709 | 15 scala就是一核武器,一个小兵都可以扔核弹,那后果将会是啥?
你不用并不代表其他人不用
【在 c******o 的大作中提到】 : Oh, come on, if you can not do it, do not do it. Cursing does not solve : anything. : Leave it to the people who can do it. : BTW, I do not use those DSL at all. Only literal functions.
|
z*******3 发帖数: 13709 | 16 不爽,所以不读scala代码
也所以用scala写的话,你可以尽情开源
反正别人读晕过去
【在 l**********n 的大作中提到】 : 这样的代码读起来很爽吗!!!
|
l*********s 发帖数: 5409 | 17 my suspect is that clojure version would be much simpler. The language is
just more coherent and has less syntax rules.
【在 c******o 的大作中提到】 : follow the type, and it is easy, just follow the type. : Same thing written in Clojure is even more difficult.
|
l*********s 发帖数: 5409 | 18 This issue could be avoid by style standards. The thing is application
developers don't have to learn or use esoteric features in scala, just like
c++ developers don't have to read STL implementations to use the library.
【在 z*******3 的大作中提到】 : scala就是一核武器,一个小兵都可以扔核弹,那后果将会是啥? : 你不用并不代表其他人不用
|
z*******3 发帖数: 13709 | 19 style standards was/is/will be always a joke
u rely on this thing? u doom
like
【在 l*********s 的大作中提到】 : This issue could be avoid by style standards. The thing is application : developers don't have to learn or use esoteric features in scala, just like : c++ developers don't have to read STL implementations to use the library.
|
q*c 发帖数: 9453 | 20 oh, come on, this is so scala style response.
Not that I can not do it, but just see people doing it generally are people
who do not care who/how to maintaining it.
BTW you do not use it, does not mean other people does not use DSL. If there
is a way, smart ass will always be there trying best to abuse it. It is
like democracy vs Dictation -- Dictation is scala, always more powerful and
efficient, but ALWAYS there will be asshole to fuck everything up. Even
super man like chairman Mao, with all the cruel and crazy deciplines he put
on, can not stop it.
We are human, it is what we do, it is what we are. So IN GOD WE TRUST, not
human "style". Human needs freedome, but also need to be forced to proper
extent, and who understand this nature of human, wins in the long run.
It is PROVEN facts.
【在 c******o 的大作中提到】 : Oh, come on, if you can not do it, do not do it. Cursing does not solve : anything. : Leave it to the people who can do it. : BTW, I do not use those DSL at all. Only literal functions.
|
|
|
l**********n 发帖数: 8443 | 21 scala code is a mixture of postfix, infix and prefix code. it is really hard
to read. even an function is an object. so you don't know whether it is a
function or an object.
you can write + X Y or X + Y or X Y +. |
l**********n 发帖数: 8443 | |
q*c 发帖数: 9453 | 23 只要大家都真正大公无私, 共产主义不就实现了吗!
【在 l**********n 的大作中提到】 : 我觉得真正熟悉了, Scala还是很强大啊。
|
z****e 发帖数: 54598 | 24 对造轮子的人有用
这样可以造出各种桥梁
让其他行业的人也能分享jvm上的成果
并创造各种java programmer的就业机会
双赢
hard
【在 l**********n 的大作中提到】 : scala code is a mixture of postfix, infix and prefix code. it is really hard : to read. even an function is an object. so you don't know whether it is a : function or an object. : you can write + X Y or X + Y or X Y +.
|