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

Pages: 1-

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))))

Name: Anonymous 2011-12-23 1:53

>>2
Common Lisp is diarrhoea.

Name: >>1 2011-12-23 2:07

I think this would make more sense in a gc is normal language, like java or some of the functional garbage collected languages where pass by reference is the only paassing.

Name: Anonymous 2011-12-24 0:06

What is this ``stack'' you speak of? There is no heap or stack, only a single-level store of tagged cons cells.

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