Arc Forumnew | comments | leaders | submitlogin
3 points by rocketnia 1267 days ago | link | parent

At one point, years ago, I relied on every lambda returning a newly allocated object. I think I brought it up as a bug in Rainbow that the [] expressions in my Arc code were generating the same lambda-lifted result instead of creating unique objects each time.

But I think this was never something I could rely on in the original, Racket-based Arc either. The Racket docs don't specify whether a lambda expression returns a new object or reuses an existing one, and in fact they explicitly allow for the possibility of reusing one:

"Similarly, evaluation of a lambda form typically generates a new procedure object, but it may re-use a procedure object previously generated by the same source lambda form."

That sentence has been in the reference since the earliest versions I can find online:

The latest docs, currently for 8.1 (2021): https://docs.racket-lang.org/reference/Equality.html#%28part...

5.0 (2010): https://download.racket-lang.org/docs/5.0/html/reference/eva...

4.0.0.1 (2008): https://web.archive.org/web/20080620030058/http://docs.plt-s...

3.99.0.13 (2008): https://web.archive.org/web/20080229164003/http://docs.plt-s...

I'm not sure if the bug you're referring to had to do with making the same mistake I was making back then, or if you're talking about making the opposite assumption (expecting two procedures to be equal), but it's probably best not to expect stability either way.



2 points by zck 1266 days ago | link

I was doing a deep-`iso` comparison I called `same`, because in Arc, hash tables are not the same. In Arc3.1:

  arc> (iso (obj) (obj))
  nil
  arc> (iso (obj 1 2) (obj 1 2))
  nil
So I made a function that iterated over the key/value pairs and compared them. In some unit tests, I used that on a hash table that contained functions. Yesterday, I refactored the unit tests to instead make sure the keys were right.

Interestingly, it seems that Anarki can compare hash tables:

  arc> (iso (obj) (obj))
  't
  
  arc> (iso (obj 1 2) (obj 1 2))
  't
Anyway, this should fix the unit test tests in the Anarki repo.

-----