[racket] I'd use an object for this in PHP, how do I handle it in racket?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Fri Nov 4 12:39:21 EDT 2011

On Nov 4, 2011, at 12:28 PM, Jordan Schatz wrote:

> I'm making an API wrapper for the WebDriver wire protocol:
> http://code.google.com/p/selenium/wiki/JsonWireProtocol#Command_Detail
> 
> In general all of the API calls require me to pass back to the server a
> token (:sessionId in the spec) that is unique to the current instance. In
> PHP or some "other" language I would create the wrapper as an object, and
> store the token in a private property. I know racket has full support for
> classes and objects, but using an object here doesn't feel like racket's
> style. 
> 
> How do I write it without using an object? What is best practice?
> 
> If it matters I'm likely to have 10-100 instances / threads of this
> running in parallel at a time... as many as I can fit on a machine.
> 
> Shalom,
> Jordan
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users


Use a closure for the callback: 

(let ((secret-token (gensym)))
  (lambda ()
     call-back-command 1
     call-back-command 2 
     ...))


Posted on the users mailing list.