[racket] Unexpected error extracting value from request bindings.
(gensym) generates something that cannot be created again in anyway.
Even it is printed as 'g1753, that doesn't mean typing 'g1753 will get
the same thing, nor that (string->symbol "g1753") will either. This is
the whole point of (gensym).
The Web server (basicaly) runs symbol->string to create the page and
then string->symbol later to turn the HTTP request in to the symbol.
When you did that to your gensym'd symbol, you got the same thing that
came out of the HTML.
As for how it works... you can think of symbols as just pointers to
table entries that contain the actual text. (gensym) basically just
uses a different table, so it's impossible for a pointer in one table
to be the same as a pointer in the other table even if the text is the
same on both table entries.
Jay
On Sun, Jul 31, 2011 at 9:07 PM, J G Cho <gcho at fundingmatters.com> wrote:
> That sounds like a black magic. I am almost tempted to ask how it's done.
>
> I imagined (gensym) would generate some unique sequence not used so
> far. Why would this approach not work?
>
> 2011/7/31 Jay McCarthy <jay.mccarthy at gmail.com>:
>> Gensym produces symbols that are not eq to any other symbols created any other way. The bindings library produces symbols from strings, so they aren't eq to the gensym'd one.
>>
>> Jay
>>
>> Sent from my iPhone
>>
>> On 2011/07/31, at 15:13, J G Cho <gcho at fundingmatters.com> wrote:
>>
>>> I am a bit puzzled by this error:
>>>
>>>
>>> Exception
>>> The application raised an exception with the message:
>>>
>>> extract-binding/single: 'q10493 not found in '((q10493 . "no"))
>>>
>>>
>>> Context:
>>> Symbol q10493 was generated by (gensym 'q) and used in
>>>
>>> (list (radio-input (symbol->string nom) "yes")
>>> (radio-input (symbol->string nom) "no")))
>>>
>>> When I try to extract it
>>>
>>> (define (extract-single nom)
>>> (λ (bindings)
>>> (extract-binding/single nom bindings)))
>>>
>>> it complains....
>>>
>>> So I changed to
>>> (define (extract-single nom)
>>> (λ (bindings)
>>> (extract-binding/single (string->symbol (symbol->string nom))
>>> bindings)))
>>>
>>> And it seems to work but left me scratching my head.
>>>
>>> Does anybody care to shed some light on this?
>>>
>>> jGc
>>>
>>> _________________________________________________
>>> For list-related administrative tasks:
>>> http://lists.racket-lang.org/listinfo/users
>>
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"The glory of God is Intelligence" - D&C 93