[racket] for/hash: bad syntax in: for/hash

From: Marijn (hkBst at gentoo.org)
Date: Tue Jan 3 12:10:38 EST 2012

Hi,

for/hash is giving me a syntax-error, but the error is in macro-expanded
code which is not shown by default and which is also seemingly
inaccessible via the macro-stepper. The for/hash expression works
outside my macro, so I guess it's my fault, but it would help if the
syntax-error could be a bit more informative. The code:


#lang racket

(require "dependent-boxes.rkt")

;;; this fails
(define model
  (dependent-boxes
   ((years)
    (income)
    (expenses)
    (profit
     (for/hash ((y years))
	       (values
		y
		(- (hash-ref income y 0)
		   (hash-ref expenses y 0) ))))  )))

;;; this works fine
(define years '(1 2 3))
(define income '#hash((1 . 100)(2 . 90)(3 . 70)) )
(define expenses '#hash((1 . 100)(2 . 90)(3 . 70)) )

(for/hash ((y years))
	  (values y (- (hash-ref income y 0)
		       (hash-ref expenses y 0) )))


The error:
$ racket test-for.rkt
test-for.rkt:12:6: for/hash: bad syntax in: for/hash

 === context ===
standard-module-name-resolver


Some help would be appreciated.

Marijn
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dependent-boxes.rkt
URL: <http://lists.racket-lang.org/users/archive/attachments/20120103/dc206a2e/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.racket-lang.org/users/archive/attachments/20120103/dc206a2e/attachment.sig>

Posted on the users mailing list.