来自 https://clojurians.slack.com/archives/C03S1KBA2/p1662437976861689
(range 0 5 1.0) ;=> (0 1.0 2.0 3.0 4.0)
(with-meta (range 0 5 1.0) {}) ;=> (5)
user=> (def x (range 0 5 1.0))
#'user/x
user=> x
(0 1.0 2.0 3.0 4.0)
user=> (with-meta x {})
(5 1.0 2.0 3.0 4.0)
我注意到可能有一些参数顺序错误的调用
Range.java中的with-meta调用
public Obj withMeta(IPersistentMap meta){
if(meta == _meta)
return this;
return new Range(meta, end, start, step, boundsCheck, _chunk, _chunkNext);
}
构造函数中的起点和终点交换了
private Range(IPersistentMap meta, Object start, Object end, Object step, BoundsCheck boundsCheck, IChunk chunk, ISeq chunkNext){