News for hackers. Stuff that matters.
Re:Show HN: Lisp with GC in 436 Bytes by jhgb on Tuesday December 21, 2021 @07:16AM (#29636628)
> a let rec construction for data

Is there actually any Lisp dialect where letrec works for data? I'm not aware of such, at least where it comes to major ones (CL and common implementations of Scheme).

Re:Show HN: Lisp with GC in 436 Bytes by JonChesterfield on Tuesday December 21, 2021 @09:50AM (#29637879)
It would need a lazy data constructor and the lisp ones are (usually) strict. If you make cons et al lazy then letrec on data works as it does in other languages. Alternatively, make letrec wrap the values in thunks. The resulting cyclic structures are then moderately annoying to work with.
Re:Show HN: Lisp with GC in 436 Bytes by jhgb on Tuesday December 21, 2021 @11:04AM (#29638681)
Oh, I forgot lazy Lisps. But those would probably not be considered "major".

> Alternatively, make letrec wrap the values in thunks.

Aaaand of course I forgot that as well. My bad. So basically full lexical scoping and the presence of lambda should be enough to create cyclic structures, even in the absence of mutability.

Re:Show HN: Lisp with GC in 436 Bytes by dan-robertson on Tuesday December 21, 2021 @08:03PM (#29644238)
Common Lisp let’s you write e.g.

  (list-length '#1=(1 2 3 4 . #1#))
But I think that isn’t what you mean.
Re:Show HN: Lisp with GC in 436 Bytes by dan-robertson on Tuesday December 21, 2021 @08:05PM (#29644261)
I don’t understand how to construct cyclic references using only letrec. Do you have a concrete example?