1

I am having trouble with an error I keep getting while trying to use formlets in racket. It says:

; lifted/5.1: undefined;
;  cannot reference an identifier before its definition
;   in module: top-level
;   internal name: lifted/5.1

Nothing in my code is named "lifted" or "5.1" or any combination of the two. I am thinking that this is something inside the black box of formlets that I'm running up against, but I don't know what.

; set up
(require web-server/servlet web-server/servlet-env)
(require web-server/formlets)

; body of program
(define simpleformlet 
   (formlet 
     (#%#
       "Name: " ,{input-string . => . name}
       "Number: " ,{input-int . => . number})
       (name number)))

(define (start request)
  (showpage request))

(define (showpage request)
  (define (responsegen embed/url)
    (response/xexpr
      `(html
         (head (title "App3"))
         (body (h1 "Let's try this...")
               (form
                 ([action ,(embed/url actionhandler)] 
                  [method "POST"])
                 ,@(formlet-display simpleformlet)
                 (input ([type "submit"])))))))

  (define (actionhandler request)
    (define-values (name number)
               (formlet-process simpleformlet request))
    (response/xexpr
      `(html
         (head (title "Alright!"))
         (body (h2 "name")
               (p ,name)
               (h2 "number")
               (p ,number)))))
  (send/suspend/dispatch responsegen))

; run it!
(serve/servlet start
    #:servlet-regexp #rx""
    #:servlet-path "/form")
Julian J
  • 13
  • 5

1 Answers1

0

I added the line

#lang racket

at the top of your program. Used "Determine language from source" in the lower, left corner of DrRacket. And ran your program. A browser window opened and I was able to enter a name and a number, before I got a sensible error.

I am using Racket version 6.12, so if you are using an older version of Racket, then upgrade and try again.

soegaard
  • 30,661
  • 4
  • 57
  • 106
  • Thank you for the help. I'm using SublimeText3 however - and the error still occurs using that. DrRacket does seem to fix it, but I'd rather use SublimeText if possible. Do you know how to determine language from source there? – Julian J Sep 10 '18 at 20:42
  • You still need to use `#lang racket` as the first line. Which racket plugin for Sublime Text are you using? – soegaard Sep 10 '18 at 20:44
  • I just figured out - I can use the longhand version of (module name racket ... ) to work. And I did try #lang racket, but that didn't seem to do anything. I am using the racket plugin mentioned in the racket documentation - is there another one? – Julian J Sep 10 '18 at 20:54
  • Don't know. I see that @follesoe has not updated the Sublime package in 4 years. If it works that is fine. If you run into problems, then check in DrRacket which is maintained by the Racket project - or try in racket-mode in Emacs, which is also up-to-date. – soegaard Sep 10 '18 at 20:58