"David L. Nicol" <[EMAIL PROTECTED]> writes:
> John Porter wrote:
> >
> > we should also support recursive data structures,
> > as in some functional languages. E.g. (pseudocode):
> >
> > define foo as {
> > short a;
> > foo b; # exists at first only "in potential".
> > long c;
> > };
> >
>
> how deep would it go? C allows you to have
>
> struct foo {
> short a;
> foo *b;
> long c;
> };
>
> because all pointers are the same size. I suppose these functional
> languages hide the implementation, allowing vivication and automatic
> dereferencing of the enclosed type as needed, transparently to the
> programmer.
Functional languages that do this are usually lazy (at least on the
"foo" argument of the constructor). That means that when you create
the structure the `foo' field stores a closure which evaluates to the
desired value. If the field is never accessed, the closure is never
evaluated and no infinite loop results.
I don't think we want this to happen automatically in Perl. Languages
with assignments do not have readily-comprehensible closures (see
e.g. Scheme's call/cc (call-with-current-continuation), which has well
defined but difficult semantics). For one thing, closures in the
presence of side-effects require a careful analysis of evaluation
order.
--
Ariel Scolnicov |"GCAAGAATTGAACTGTAG" | [EMAIL PROTECTED]
Compugen Ltd. |Tel: +972-2-6795059 (Jerusalem) \ We recycle all our Hz
72 Pinhas Rosen St. |Tel: +972-3-7658514 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555 http://3w.compugen.co.il/~ariels