[plt-dev] #hash vs. #s

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Feb 9 10:45:23 EST 2009

Done in SVN (v4.1.4.3). Infix notation for prefabs is also now enabled.


At Sun, 8 Feb 2009 17:57:56 -0700, Matthew Flatt wrote:
> Thanks!
> 
> Now that I try your patch, though, I see a problem that I overlooked
> before. In the syntax system, a hash table is not treated like pairs,
> vectors, boxes, or prefabs, in that lexical information is not
> propagated from the hash table to its content.
> 
> As a result, the example
> 
>   (let ([x 5]) `#hash(("coconut" . ,(+ 1 x))))
> 
> doesn't work.
> 
> I'll look into changing the syntax system to propagate information into
> the values (and not the keys) of hash tables, and I'll save your
> patches until that change is ready.
> 
> At Sun, 08 Feb 2009 14:08:44 -0500, Dave Herman wrote:
> > Patch for collects/tests/mzscheme/syntax.ss attached.
> > 
> > Dave
> > 
> > Dave Herman wrote:
> > > Attached is a patch for collects/scribblings/reference/syntax.scrbl that 
> > > documents the quasiquote behavior. I'll create some new quasiquote tests 
> > > and send a patch for that tomorrow.
> > > 
> > > Dave
> > > 
> > > 
> > > On Feb 6, 2009, at 11:52 PM, Dave Herman wrote:
> > > 
> > >>> Oops --- I meant to vote for "1", not "2".
> > >>>
> > >>>> Doesn't that mean that some hash tables that should have literal
> > >>>> representations won't?
> > >>>
> > >>> Yes, at least in terms of quasiquote. That's a good reason against 2.
> > >>
> > >> Okay, patch attached. Not sure if I did this right but hopefully it 
> > >> helps.
> > >>
> > >> Dave
> > >> <qq-and-or.patch>
> > >> _________________________________________________
> > >>  For list-related administrative tasks:
> > >>  http://list.cs.brown.edu/mailman/listinfo/plt-dev
> > > 
> > 
> > --- /home/dherman/Desktop/syntax.ss	2009-02-08 14:06:49.743750000 -0500
> > +++ syntax.ss	2009-02-08 14:05:32.353125000 -0500
> > @@ -651,6 +651,28 @@
> >  (test '(quasiquote (quasiquote (quasiquote (unquote (unquote (unquote 
> x)))))) 
> > 'qq ````,,,x)
> >  (test '(quasiquote (quasiquote (quasiquote (unquote (unquote (unquote 
> 5)))))) 
> > 'qq ````,,,,x)
> >  
> > +(test '#hash() 'qq `#hash())
> > +(test '#hash(("apple" . 1) ("banana" . 2) ("coconut" . 3))
> > +      'qq
> > +      `#hash(("apple" . 1) ("banana" . 2) ("coconut" . 3)))
> > +(test '#hash(("apple" . 1) ("banana" . 2) ("coconut" . 3))
> > +      'qq
> > +      `#hash(("apple" . ,1) ("banana" . ,(add1 1)) ("coconut" . ,(+ 1 2))))
> > +(test '#hash(("foo" . (1 2 3 4 5)))
> > +      'qq
> > +      `#hash(("foo" . (1 2 ,(+ 1 2) 4 5))))
> > +(test '#hash(("foo" . (1 2 3 4 5)))
> > +      'qq
> > +      `#hash(("foo" . (1 2 ,@(list 3 4 5)))))
> > +(test '#hash((,(read) . 1) (,(+ 1 2) . 3))
> > +      'qq
> > +      `#hash((,(read) . 1) (,(+ 1 2) . ,(+ 1 2))))
> > +(test '#hash((,(read) . 2))
> > +      'qq
> > +      `#hash((,(read) . 1) (,(read) . 2)))
> > +(syntax-test #'`#hash(("foo" . ,@(list 1 2 3 4 5))))
> > +(error-test #'(read (open-input-string "`#hash((foo ,@(list 1 2 3 4 5)))")) 
> > exn:fail:read?)
> > +
> >  (test '(quasiquote (unquote result)) 'qq `(quasiquote ,result))
> >  (test (list 'quasiquote car) 'qq `(,'quasiquote ,car))
> >  
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-dev


Posted on the dev mailing list.