chicken-janitors
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-janitors] #943: typed-records: defstruct breaks with default va


From: Chicken Trac
Subject: [Chicken-janitors] #943: typed-records: defstruct breaks with default values
Date: Mon, 29 Oct 2012 20:13:51 -0000

#943: typed-records: defstruct breaks with default values
------------------------+---------------------------------------------------
 Reporter:  megane      |       Owner:         
     Type:  defect      |      Status:  new    
 Priority:  major       |   Milestone:  someday
Component:  extensions  |     Version:  4.8.x  
 Keywords:              |  
------------------------+---------------------------------------------------
 The expected output is shown in case 3. In this case the slot for 'a' is
 defined as `(a : fixnum)`.

 If the default is given the slot and accessor indices are reversed, and
 with `-specialized` just the slot indices are reversed.

 {{{
 (use typed-records)

 (defstruct bar
   ((a 100) : fixnum)
   (b : fixnum))

 (define (create-bar a)
   (let* [(b (make-bar a: a b: 42))]
     (print "(bar-a b) " (bar-a b))
     (print "(bar-b b) " (bar-b b))
     (print "(##sys#slot b 1) " (##sys#slot b 1))
     (print "(##sys#slot b 2) " (##sys#slot b 2))
     b))

 (create-bar 1)

 ;; 1. no -specialize
 ;; (bar-a b) 1
 ;; (bar-b b) 42
 ;; (##sys#slot b 1) 42
 ;; (##sys#slot b 2) 1

 ;; 2. with -specialize
 ;; (bar-a b) 42
 ;; (bar-b b) 1
 ;; (##sys#slot b 1) 42
 ;; (##sys#slot b 2) 1

 ;; 3. without the default `100' for slot `a'
 ;; (bar-a b) 1
 ;; (bar-b b) 42
 ;; (##sys#slot b 1) 1
 ;; (##sys#slot b 2) 42

 }}}

-- 
Ticket URL: <http://bugs.call-cc.org/ticket/943>
Chicken Scheme <http://www.call-with-current-continuation.org/>
Chicken Scheme is a compiler for the Scheme programming language.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]