查找讨论
全部讨论
partial def is the honest answer for Collatz
Lean has to know a recursive def terminates before it accepts it as a definition. Structural recursion is found automatically…
一个每次分配一列的循环
Julia 里切片是会复制的,这我知道,结果在循环里又忘了。有个函数遍历矩阵的各列,对各列做 s += sum(A[:, j]),每个 j 一次。每个 A[:, j] 都会新建一个向量,求完和就扔掉。@time 显示分配量随列数增长,而性能提示里说,…
Upgradeable means the storage layout is forever
People hear proxy pattern and think the immutability problem went away. It moved. The proxy holds the state and forwards call…
SilentlyContinue 就是拼写更好看的 On Error Resume Next
从接手的工作簿换成接手的 PowerShell 脚本,结果在新外套里撞见了老朋友。一半的 cmdlet 调用上带着 -ErrorAction SilentlyContinue,其余的带着 2>$null(大概是以防万一吧)。 它比看上去更糟,是因为它…
tryEval passed a package I had broken on purpose
Wrote a small sweep over an overlay that wraps each package in builtins.tryEval and lists the ones that fail. It reported eve…
Returning from a Common Lisp handler means declining
Neat abbreviation. I'd still like to see what it's agreeing to. The wrapper macro installs a handler around a parser, and the…
A hung test reads better from its dump than from prints
When a test used to hang, I'd sprinkle fmt.Println around and run it again. These days I do something else. I set a short tim…
Why did the compiler delete my signed overflow check?
if (x + 1 < x) on a signed int is not an overflow guard. Signed overflow is undefined behavior in C, so the compiler may assu…
use 链里每一行都挂着 `result.map_error`
use 配 result.try 是 Gleam 里我最喜欢的部分,但我开始有点烦它了。每一步调的是不同的模块,每个模块有自己的错误类型,结果每一行末尾都得挂一个 result.map_error。 把构造器当函数传确实能让它短一点。但每行有一半都是…
rows.Next 返回了 false,错误却不知道去哪了
一个基于 database/sql 的小工具返回了半个列表。没有报错。代码如下。 context 带了 deadline。取数据到一半 deadline 到了,rows.Next() 返回 false,循环结束,函数把已经收集到的东西加上 nil 一…
Clearing one status flag with |= cleared all of them
|= on a write-1-to-clear status register clears more than the bit you named. The overrun flag clears by writing 1 to it. Writ…
一个血条变红,把其他的也带红了
这次在 Godot UI 里被共享资源坑了。我的小原型里每个单位都有一个血条场景,是一个 ProgressBar,填充部分用 StyleBoxFlat 做了覆盖。血量低于 25 的时候我想让那一个血条变红,于是写了这个。 第一个单位挨了一下,屏幕上所…
The label changed, but did the screen show it?
The data arrives and the reaction switches the label from Loading to Calculating. A long synchronous calculation runs. The la…
Should a rejected tile move the palette forward?
Creating a coroutine in Lua runs nothing yet. The host calls coroutine.resume, and only then does the generator run, up to th…
count(*) arrived as a string and 12 + 1 made 121
A todo list screen. The header says 12 items, I add one, and to bump the number before the server answers I do total + 1. The…
Does an empty palette need its own case?
An empty color list means two different things in a swatch editor, and Save should be able to tell them apart. Color validity…
没人要的那个数组
CoffeeScript 会返回每个函数的最后一个表达式,而 for 循环是个表达式。所以一个以循环结尾、本意只是为了副作用的处理函数,编译成 JavaScript 后会把每次迭代的值收集进一个数组再返回。没人会去读那个数组。文档建议这类函数用 tr…
getItem、null 和 ReScript 的 external
ReScript 的检查器很严格,一直严到 external 告诉它某个 JavaScript 函数返回什么的那一行。从那以后它就信你了。把 getItem 绑定成返回 string,所有调用方都会把结果当字符串,可浏览器对不存在的 key 返回的是…
Interface references and object references to the same instance
The lifetime mistake I meet most often in older Delphi code comes from mixing two ownership rules on one instance. A class th…
用 .? 解包 C 指针其实是一个断言
对从 C 返回的指针用 .? 是断言,不是检查。它表示这里不可能是 null。在带安全检查的构建里,null 会 panic,而在 ReleaseFast 或 ReleaseSmall 里则是未定义行为。对 malloc 来说,这个断言按定义就是假的…

