[racket] Lambda, object identity & streams

From: Bradley Lucier (lucier at math.purdue.edu)
Date: Thu Apr 17 12:46:08 EDT 2014

> In the process of toying with streams & memoization (more below), I've 
> tripped over the question: when does Racket consider two lambdas to be 
> identical?

I came across the same question when working with my constructive reals package.  (A constructive real number is basically a function that returns a stream of integers of various kinds, depending on the representation.)

For example, could I tell that "one" "plus" "one" equals (returns the same stream of integers) "two" "times" "one" (where all the quoted terms are in the constructive reals).

Using Gambit, I couldn't figure out how.

But there was a way to see that "one" "plus" "one" equals (another instance of) "one" "plus" "one", and that was to serialize both lambdas computing the two constructive reals and then to compare the serialized values.  The serialized lambdas "remembered" how they were composed from simpler lambdas, so if two of them were constructed using the same sequence of operations, then the serialized representations could tell that they were the same, while they were stored as two different closures in memory.  I still couldn't tell that "one" "plus" "two" equals "two" "plus" "one".

I didn't go much further with the question of how different representations of lambdas might facilitate checking "equality" of more general terms.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140417/a293b6d8/attachment.html>

Posted on the users mailing list.