>>11
Actually CL does have pointers (in most implementations), just they're not portable and using pointers in high-level languages means you have to babysit the GC.
However, I almost never had any need to use pointers in CL after I learned it:
- Use generalized places with
SETF
- Use structures, objects, lists, closures, ... (passed by reference; most things are, except atoms such as numbers)
- You really, really want pointer-like functionality? Generalized places can be easily encapsulated into an object and you can change or modify it (just like reference/dereference in C). This is known as `locatives' from LispMachineLisp. Portable implementation for CL:
http://permalink.gmane.org/gmane.lisp.sources.code/17 If you want very fast, unportable ones (if you use them often), here's an SBCL extension:
http://discontinuity.info/~pkhuong/mcas/sb-locatives.lisp . Original LispM docs about them:
http://www.unlambda.com/lmman/lmman_18.html
- In C, you commonly use pointer arguments to return multiple results or modify structures: you don't need to do this in CL, you can just return multiple values, or modify the structure directly (of course, it's bad coding practice to do this without specifying that the function does this).
Even if you can fully emulate pointers using locatives, I rarely used this feature, as it's nicer to just write CL like it was meant to be written.
>>12
It's only inefficient and ugly because you don't know how to write it better. I almost never had to write anything like that myself (although I did write something similar when I was learning the language). If you really can't live without pointers, use locatives, although you'll probably be better off learning to write in a better style.