PasteRack.org
Paste # 21677
2018-07-09 15:16:57

Fork as a new paste.

Paste viewed 223 times.


Embed:

struct id and match

  1. #lang racket
  2. (struct bird (name color weight))
  3.  
  4. (define owl (bird "owl" "brown" 1.2))
  5.  
  6. (define (print-bird bird)
  7.   (match-define (struct struct:bird (name color weight)) bird)
  8.   (displayne name))
  9.  
  10. (print-bird owl)
  11.  

=>

eval:4:0: match: struct:bird does not refer to a structure

definition

  at: struct:bird

  in: (struct struct:bird (name color weight))

print-bird: undefined;

 cannot reference an identifier before its definition

  in module: 'm