openlang
04 /搜索

查找讨论

全部讨论

  1. 重复 Timer 里的 unowned self 只是把崩溃往后推

    为了去掉可选值,我把 [weak self] 换成了 [unowned self],用在一个重复 Timer 的块里,然后关掉了这个界面。下一次 tick 就崩了。 没什么玄机。run loop 会让已调度的 timer 一直活着,而 timer 又…

    回复 2最近活动 swift
  2. sum(X) on a matrix with one row

    A function takes a matrix of observations, rows are observations and columns are features, and normalizes each column with X…

    回复 6最近活动 matlab
  3. Isolate.run took my whole Loader with it

    Moved a big JSON decode off the main isolate with Isolate.run and got an error about an unsendable object instead of a speedu…

    回复 2最近活动 dart
  4. 迁移到一半的 Scala 3 文件里,implicit vs given

    说实话,Scala 3 保留 implicit 是对的,但它还是每周都让我烦。 说对,是因为没人需要在第一天就重写整个代码库。旧式 implicit 仍然能编译,Scala 3 可以用为 2.13 构建的库,你可以一次一个文件地迁移到 given 和…

    回复 3最近活动 scala
  5. 只读的 List<Int> 算快照吗?

    List<Int> 是只读视图,不是快照。它只告诉使用方,通过这个引用可以调用哪些操作,并不保证它背后的集合不会变。 比如 val owned = mutableListOf(2, 4)。调用方把 owned 传给一个接收 List<Int> 的函数…

    回复 4最近活动 kotlin
  6. Validating JSON before the discriminated union

    A type assertion only tells the compiler what to believe. An external response starts as bytes and says nothing about its var…

    回复 9最近活动 typescript
  7. NOT IN and one NULL

    SELECT * FROM orders o WHERE o.customer_id NOT IN (SELECT id FROM blocked) returns nothing at all once blocked.id holds a sin…

    回复 16最近活动 sql
  8. 用度量单位做低成本的 id

    对整数 id,我一直在试用度量单位来代替单分支联合类型,想在它扩散开之前听听别人的意见。CustomerId of int 除非标上 [<Struct>] 否则会分配内存,而且每次使用都要经过构造器或 match。用 [<Measure>] type…

    回复 1最近活动 fsharp
  9. 空单元格既等于零又等于空字符串

    接手了一个宏,用来标出数量为零的订单行,结果它把每个空行也标出来了。检查写的是 If ws.Cells(r, 4).Value = 0 Then。空单元格返回的是一个装着 Empty 的 Variant,而 Empty 和 0 相等(和 "" 也相等…

    回复 3最近活动 vba
  10. 我的大部分宏最后都变成了 const 和 static

    Nim 写宏太容易了,问题就出在这儿。 在动手写 macro 之前,先看看更便宜的工具。const 是在编译期求值的,用的就是跑宏的那个 VM,所以由普通 proc 构建的查找表直接写成 const table = buildTable() 就行。s…

    回复 3最近活动 nim
  11. 像老 C++ 那样按字节截断,Rust 直接 panic

    在把一段老 C++ 移植到 Rust,它把 std::string 用一句普通的 s.substr(0, n) 截到字节上限,我本来以为一行就搞定了。在 C++ 里它大致能用,尽管 std::string 对 UTF-8 一无所知,会毫不犹豫地把一个…

    回复 4最近活动 rustcpp
  12. A helper ported from Java picks a different overload in Groovy

    Moved a Java helper class into Groovy on the build script side, and the same call went to a different method. Laid out in ord…

    回复 3最近活动 groovyjava
  13. NFC 查找键与 JCS 签名

    签名让 kim_dh 之前问的 NFC 查找键的问题变复杂了,那个问题把提交的名字和 NFC 查找键分开处理。一个 JSON 载荷里有个名字,拼写是 e 后面跟着 U+0301,这个字符串会进入基于 JCS 的签名。 RFC 8785 对解析出来的…

    回复 3最近活动 typescript
  14. Result 说明检查失败了,opaque 证明检查跑过了

    大家都夸 Gleam 把错误当值来处理,这没毛病,Result 确实很讨喜。但做数据建模时,我更依赖的是 opaque。 pub opaque type Email { Email(String) } 的意思是,其他模块能看到这个类型,但不能调用它的…

    回复 3最近活动 gleamelm
  15. A partial index and a parameter in the WHERE clause

    A partial index is used only when the planner can show that the query's WHERE implies the index predicate. The docs say the m…

    回复 0最近活动 sqlgo
  16. memset before free is a dead store

    memset(key, 0, len) followed by free(key) is not a wipe. Nothing reads the buffer again, so the store is dead, and the standa…

    回复 1最近活动 c
  17. 引用依赖里的定理之前,先看它用了哪些公理

    能编译通过的定理还不等于有证明的定理。sorry 能关掉任何目标,Lean 会接受这个文件,只给一个警告。在别处构建的依赖里,这个警告你是看不到的。 #print axioms 就是检查手段。它会顺着定理用到的每个常量,传递地往下追,列出它们触及的公…

    回复 1最近活动 lean-4
  18. errdefer 里的 free 在成功路径上泄漏了

    一个测试泄漏了内存,而且泄漏出在成功的那条路径上。函数分配了一个临时缓冲区,解析出一个归调用方所有的结果,并用 errdefer allocator.free(scratch) 释放这个临时缓冲区。所有错误路径都释放了它。成功返回却没有,测试结束时…

    回复 2最近活动 zig
  19. A println inside the swap! function

    The docs for swap! say the function may be called multiple times and should be free of side effects. Code in the wild still l…

    回复 1最近活动 clojure
  20. 在 -O0 或 -O2 下读 RISC-V 调用约定

    调用约定从真实的编译器输出里读,比背寄存器表记得牢。一个不错的练习是写个 C 函数,三个 int 参数,返回它们的和,针对 RV32 分别用 -O0 和 -O2 编译一次。 -O0 的汇编输出很杂。函数先建立栈帧,把 a0、a1、a2 存到栈上,再读…

    回复 5最近活动 assemblyc