Thanks. I wrote a rudimentary syntax transformer, but really I don't know the 
best way to work around this -- and I'm not very proficient with syntax 
transformers. I could put all of my code which I would prefer to be top level 
in a procedure/let context, but I don't really think this is the solution I'm 
looking for.

For example, I want to put some example data read by my port->list helper 
procedure in the top level for experimenting, but I'm sure there are more 
serious use cases for my issue.

Here's a very basic solution I just came up with. Any ideas would be 
appreciated:

#lang typed/racket

(define-syntax guard
  (syntax-rules ()
    [(_ a b)
     (let ()
       (unless (a b)
         (error "guard failed"))
       b)]))

(define ls (port->list read (open-input-string "1 2 3 4")))
(for ([n (guard (λ (ls) (andmap number? ls)) ls)])
  (displayln (* n n)))

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to