查找讨论
全部讨论
asyncio.TaskGroup when one fetch fails
Concurrency comparisons between languages usually start with syntax. I'd start with what the calculation needs when something…
What the canary check looks like at -O2
Three small C functions, gcc -O2 -fstack-protector-strong -S -masm=intel, x86-64 Linux. read_line and read_count get the same…
GOMAXPROCS in a container now follows the CPU limit
Before Go 1.25, GOMAXPROCS defaulted to the logical CPU count of the machine. A container limited to two CPUs on a host with…
Where does the cursor stay after an incomplete record?
Result tells the caller of a streaming parser whether a record came out. It says nothing about whether the parser moved a cur…
我的 init 只给一个 buffer 设置了 fill-column
我的 init 里写了很久的 (setq fill-column 72),直到刚才才发现新建 buffer 里按 M-q 还是在 70 处折行。(在 *scratch* 里是在 72 处折行,我就是这样骗了自己。) fill-column 是自动 b…
Wrapping exceptions without losing the cause
new ImportFailure("Import failed") is all that reaches the diagnostic log once the import tool catches a low-level failure an…
Why would this CPS sum overflow only in Debug?
Could someone check my reading of this? A continuation-passing sum, written as an exercise. dotnet run -c Release prints 1000…
评审里指出循环引用,有用的评论会点明谁是所有者
“到处用 weak 就行了”这种评审评论,作者其实没法回应。 常见的情况是子对象持有一个指回父对象的 delegate 引用,而父对象拥有它。有两种评论能让作者有东西可做,一种是“delegate 能不能改成 weak,如果父对象已经不在了,子对象就…
一个把“Saved”读了两遍的状态区域
一次保存之后,屏幕阅读器把“Saved”读了两遍。它背后的状态只有一次转入 saved 的转换,reducer 的测试也证明了这一点。 变了两次的是 DOM。状态组件只在有消息时才渲染这个区域,大致是 message && <p aria-live=…
Mode line columns drift as soon as a buffer name has Hangul in it
Padded the buffer name in my mode line to a fixed width so the bits after it line up, and it worked for a long while (well, i…
round(2.5) 得 2,学习者不信
学习者总是猜 round(2.5) 是 3,而我常用的两门语言都说是 2。Python 给出整数 2,Julia 给出 2.0。两者都把恰好在中间的数舍入到最近的偶数,所以 round(0.5) 是 0,round(1.5) 是 2,只有把几个这样的…
迁到 Kotlin DSL 之后,子项目找不到 implementation 了
把一个老的多项目构建从 Groovy DSL 迁到 Kotlin DSL。根目录的 build.gradle 里有这么一段。 根目录这部分我是机械地转换的。 那就按顺序说。 根脚本能编译,这块没问题。 在子项目 core/build.gradle.k…
Testing a Go channel handoff without sleep
Most handoff tests I run into end with a sleep and a hopeful assertion. This one can do without. A request carries an identif…
手工翻译老 CoffeeScript 是一堂不错的 JavaScript 课
一个不时髦的练习,效果却好得出乎意料。给学习者一个旧的小 CoffeeScript 文件,让他们不跑编译器,直接改写成现代 JavaScript。 几乎每一种语法糖都有对应的现代写法,重点就在这里,因为这些对应物很接近但并不完全相同。@name 是…
getline hands you the buffer even when it fails
POSIX getline allocates or grows the buffer through the pointer you pass, and the buffer belongs to the caller from the first…
从 C 回调进来会丢掉我设置好的 arena
一个 C 库会回调我的 Odin 代码,而回调看不到我在注册它之前设置好的 context。proc "c" 没有隐式 context,所以得自己建一个,而 runtime.default_context() 给的是默认分配器,不是注册代码里 con…
空归约返回单位元
对空向量做归约,APL 有答案。 每个原语都自带它的单位元。加法是 0,乘法和与是 1。⌈/⍬ 给出解释器里最小的负数。调用方不需要特殊处理,归约之前也不用检查长度。 dfn 就没有这种待遇。{⍺+⍵}/⍬ 在 Dyalog 里是 DOMAIN ER…
3 + 4 * 2 等于 14,这还只是简单的部分
每个刚学 Smalltalk 的人很早就会碰到 3 + 4 * 2,然后被告知结果是 14,因为二元消息从左到右求值,完全没有算术优先级。这一点看一次演示就记住了(它确实只是两次发送,先把 + 发给 3,再把 * 发给返回的任何东西,数字也没有任何特…
for_each 的 key 是地址,不是标签
for_each 的 key 不是标签。它是资源地址的一半,比如 terraform_data.queue["prod-orders"],state 就是在这个地址下跟踪对象的。改了 key,plan 看到的不是重命名,而是一个要销毁的对象和另一个要…
别把循环和条件写进 build.gradle
碰到过一个 build.gradle,一半的逻辑都写在闭包里,而这些闭包的 delegate 在运行时被重新指派了。花了好一阵才搞清楚每样东西是什么意思。 Groovy 让这种事很容易。闭包默认先在 owner 上解析不带限定的名字,而 DSL 会把…