[plt-scheme] readable hash tables?

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Sep 5 22:15:52 EDT 2006

He means this:

[:~] matthias% mzscheme
Welcome to MzScheme version 352.5, Copyright (c) 2004-2006 PLT Scheme  
Inc.
 > (print-hash-table #t)
 > #hasheq(('a . 1))
#hasheq(((quote a) . 1))
 > (define out (open-output-string))
 > (display #hasheq(('a . 1)) out)
 > (close-output-port out)
 > (get-output-string out)
"#hasheq(((quote a) . 1))"
 > (define in (open-input-string (get-output-string out)))
 > (read in)
#hasheq(((quote a) . 1))

-- Matthias





On Sep 5, 2006, at 10:05 PM, Chongkai Zhu wrote:

>
> When the print-hash-table parameter is set to true (see section  
> 7.9.1.4), hash tables print using the form #hash((key . val) ...)  
> or #hasheq((key . val) ...) for tables using equal? or eq? key  
> comparisons, respectively. If the print-hash-table parameter's  
> value is #f, hash tables print unreadably as #<hash-table>. Hash  
> tables with weakly held keys always print unreadably as #<hash-table>.
>
>
> Expressions of the form #hash((key-datum . val-datum) ...) are  
> literal immutable hash tables. The hash table maps each key-datum  
> to its val-datum, comparing keys with equal?. The table is  
> constructed by adding each key-datum mapping from left to right, so  
> later mappings can hide earlier mappings if the key-datums are  
> equal?. An expression of the form #hasheq((key-datum . val- 
> datum) ...) produces an immutable hash table with keys compared  
> using eq?. If the value of read-square-bracket-as-paren parameter  
> (see section 7.9.1.3) is true, matching parentheses in a #hash or  
> #hasheq constant can be replaced by matching square brackets.  
> Similarly, matching curly braces can be used if read-curly-brace-as- 
> paren is true.
>
>
> ----- Original Message -----
> From: "Paul Graham" <pg at ycombinator.com>
> To: <plt-scheme at list.cs.brown.edu>
> Sent: Tuesday, September 05, 2006 7:53 PM
> Subject: [plt-scheme] readable hash tables?
>
>
>> Is there any provision in metropolitan mzscheme for writing
>> hash tables in a way that they can be read back in by read?
>>
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.