Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

explicit stack allocation and implicit gc

Name: Anonymous 2011-12-23 1:05


int* f() {
  int a = 2; // <<---
  return &a; // uses escape analysis to determine that a must be an object in a garbage collected heap, or a reference counted object on the heap, since ints can't reference other stuff to make cycles.
}



int* f() {
  stack int a = 2;
  return &a; // uses escape analysis to determine that this will lead to memory errors, and wont compile.
}


what doya think?

Name: Anonymous 2011-12-23 1:15

Cool code. Try this instead:

(defun read-text (stream)
  (when stream
    (loop for line = (read-line stream nil)
     while line do (format t "~a~%" line))))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List