From: | Hans-Peter Diettrich <DrDiettrich1@aol.com> |
Newsgroups: | comp.compilers,comp.lang.functional |
Date: | 27 Apr 2007 14:35:01 -0400 |
Organization: | Compilers Central |
References: | 07-04-074 07-04-084 07-04-109 07-04-125 |
Keywords: | Java, OOP, design |
Posted-Date: | 27 Apr 2007 14:35:01 EDT |
Chris F Clark wrote:
> You can get polymorphism, by using C++ as your C...
> That leaves GC...
I don't know whether polymorphism is a requirement for writing
compilers, some opinions deny just the requirement of OOP.
About GC, it can come in handy, but IMO if you don't care about memory
(leaks...), you don't need it, and if you care, you shouldn't use it ;-)
> Here is the point I want to debate/discuss. What C and its semantic
> (if not syntactic) cousins Pascal and PL1/G have is the ability to
> create a modify complex graph structures (with complex vertexes and
> edges) in place (i.e. by side-effect). (This ability exists in all
> languages where one can explicitly manipulate pointers and not just
> lists.)
I prefer to distinguish between pointers and references, as C++ does.
Pointer arithmetic is dangerous, references are a requirement for OOP,
and are safe unless referenced objects are erroneously destroyed.
Leaving the destruction to GC is not a replacement for proper object
management ;-)
I think that we don't need another discussion of my ;-) opinions.
> So, this is the question, is there an FP technique that allows
> inidividual elements of an array (list, bag, someother roughly
> equivalent structure) to be addressed and arbitrary (i.e. cyclic)
> graphs to be constructed (and rearranged) on-the-fly, but where
> unreferenced elements get collected? If so, where can I learn about
> it?
Such a usable techique just is mark-sweep. Where "traditional" garbage
collection must know about the location of references, in your
index-based model it must know about the location of indices. In all
cases RTTI is a requirement for GC, and type safety at least is desireable.
One variation of GC uses reference counting for the determination, when
an object becomes unused. This model has some problems, e.g. with
circular references, but it can be implemented even without RTTI
support, and can be made work also with cyclic references.
Literature? Sorry, I cannot recommend specific literature. The
documentation of the Boehm GC may contain some helpful information.
Reference counting should be self-explanatory...
DoDi
Return to the
comp.compilers page.
Search the
comp.compilers archives again.