;; chicken-bind generates helpers when it encounters structs. ;; the generated helper to create a new struct look like this: (define make-point (foreign-lambda* (c-pointer (struct "point")) ((float x) (float y)) "struct point *tmp_ = (struct point *)C_malloc(sizeof(struct point));\ntmp_->x = x;\ntmp_->y = y;\nC_return(tmp_);"))) ;; This is not ideal, since you have to remember to free that struct-pointer later. ;; I would like the new struct to be a scheme-object automatically GC'ed ;; by chicken instead. I also want to take advantage of Chicken's fast ;; memory-allocation by using the stack. ;; Here is my suggestion: ;; <------------ ;; returns a blob: (define %make-point (foreign-primitive scheme-object ((float x) (float y)) #<x = x; _struct->y = y; *((C_header*)ab) = C_BYTEVECTOR_TYPE | sizeof (struct point); C_return (ab); END )) ;; returns a locative (define (make-point x y) (location (%make-point x y))) ;; --------------->