duangsuse::Echo
583 subscribers
4.12K photos
118 videos
579 files
6.13K links
import this:
美而不丑、明而不暗、短而不凡、长而不乱,扁平不宽,读而后码,行之天下,勿托地上天国。
异常勿吞,难过勿过,叹一真理。效率是很重要,盲目最是低效。
简明是可靠的先验,不是可靠的祭品。
知其变,守其恒,为天下式;穷其变,知不穷,得地上势。知变守恒却穷变知新,我认真理,我不认真。

技术相干订阅~
另外有 throws 闲杂频道 @dsuset
转载频道 @dsusep
极小可能会有批评zf的消息 如有不适可退出
suse小站(面向运气编程): https://WOJS.org/#/
Download Telegram
#kt #歪点子 inline class 来了,const fun 就端上来罢🤓🤏 https://youtrack.jetbrains.com/issue/KT-14652
https://kotlinlang.org/docs/inline-classes.html


const val x = encrypt("password")
const val hash = md5(File("config.file")

val routes = arrayOf(
get("/hello", (req, res) -> "Hello World");
get("/fizz", (req, res) -> "bazz");
);
dispatch(routes); //2* if

const val MEMORY_SIZE = 640.kb //fails now
const fun p(num: Int) = it == 0
typealias Zero = Int / ::p
//现在的带验证类型
value class Even(val num: Int) {
companion object {
operator fun contains(num: Int) = num % 2 == 0
}
}
& being able to use the return value of a constexpr function as an annotation


replies Andrey Breslav:
The main use-case is 'documentation'. See the resent example of discussion for "nameof" here: https://discuss.kotlinlang.org/t/nameof-to-get-names-of-program-elements/1518/4

https://github.dev/rust-lang/rust/tree/master/library/std

there are apparently 990 functions in their stdlib that have been converted as const fns

https://tech.youzan.com/java-metaprograming/ #learn 元编程是什么?为什么js人搞JSON不需要靠元编程?

编程,就是用SDK给的套路解决问题。
元编程,就是突破病态类型(仅编译期可见的静态类型) 的桎梏,编写能写代码的代码,即codegen函数,从而实现编译器没有自带的功能,例如打印“class指针”里的内容

☺️我有一个绝妙的点子替掉 https://square.github.io/kotlinpoet/ ,只是手里的屏幕有点小,写不下
https://github1s.com/bennyhuo/Kotlin-Trim-Indent/blob/master/trimindent-compiler/src/main/java/com/bennyhuo/kotlin/trimindent/compiler/TrimIndentIrGenerator.kt#L34-L81

瞄了一眼,发现截获覆盖字面量调用是挺简单的