Where does the function come from?

This code works:

(define list-of-events 
  (for/list ([(date code)
              (in-query odc "select date, code from attendance
                             where student_id = ? and term_code = ?"
                        "12345" "654321")])
    (make-attendance-event date code)))

      

However, when I try to duplicate the behavior for another table, the parallel item for make-attendance-event complains that it is an "unbound identifier".

Now where does the make-attendance-event come from?

+3


source to share


2 answers


The identifier make-attendance-event

came from (define-struct attendance-event (...))

.

A structure definition such as

(define-struct foo (a b))

      

will expand to multiple definitions.

  • make-foo will build foo structures
  • foo-a, foo-b for field access
  • Foo? a predicate that can determine if the value is foo


In an additional language, you will also receive:

  1. set-foo-a !, set-foo-b! to change the corresponding fields.

More details here: http://docs.racket-lang.org/htdp-langs/advanced.html?q=define-struct#%28form._%28%28lib._lang%2Fhtdp-advanced..rkt%29._define -struct% 29% 29

Note that you can hover over an identifier make-attendance-event

in DrRacket, right-click and select Go to Binding Occurrence to see where the identifier is defined.

+5


source


make-attendance-event is a function defined elsewhere in your Racket file. This is not a library function.



+1


source







All Articles