home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!caen!sol.ctr.columbia.edu!news.cs.columbia.edu!mail
- Newsgroups: comp.lang.scheme
- Date: Sun, 22 Nov 92 16:51:02 EST
- From: thayer@cs.columbia.edu (Charles Thayer)
- Message-ID: <9211222151.AA09161@cs.columbia.edu>
- Subject: Re: Re^2: Closures, Object-Oriented Equivalence, New version of Perl and TCL
- In-Reply-To: <736@data.rain.com>
- References: <9211110521.AA01343@cs.columbia.edu> <9211180509.AA04035@cs.columbia.edu>
- Lines: 93
-
- In article <736@data.rain.com> you write:
- >thayer@cs.columbia.edu (Charles Thayer) writes:
- >
- >>:) Which brings up an interesting point in mit-scheme:
- >
- >>(begin
- >> (define a "moo")
- >> (define (foo)
- >> (display a)
- >> (define a "bar")
- >> )
- >> (foo))
- >
- >>=> Unassigned variable a
- >
- >
- >This is because the above is equivalent to the following:
- >
- >(letrec ( (a "moo")
- > (foo
- > (lambda ()
- > (display a)
- > (define a "bar")) ;; <- ill-placed define
- > )
- > )
- > (foo)
- >)
- >
- >The semantics of "internal defines" is that of LETREC (parallel
- >assignment) and
- >*** definitions must occur before other expressions within a block ***
- >
- >This difference between "internal defines" and "top-level defines"
- >has been a subject of debate for some time. I am not taking a
- >position here, just trying to insure that the definition is
- >understood.
- >
- >-Ken
-
- I recognized the fact immediately because it was also discussed in the
- realm of C++, which is even more complicated because of the
- distinction neccessary for object construction.
-
- foo() {
- cout << "test" << endl; // declarations don't have to be at the top
- // of a block
- FooObj foo; // calls FooObj();
- FooObj bar = 10; // calls FooObj(int 10);
- FooObj baz; // calls FooObj();
- baz = 10; // then op=(FooObj& baz, int 10);
- FooObj moo(10); // calls FooObj(int 10), moo is like bar
- }
-
- A scheme programmer might wish to ask ``can I "cout << foo << endl;"
- lexically before the declaration of foo?'' Which would introduce the
- paradox for bar and moo which have initializers.
-
- Anyway, I was hoping to point out this particular language
- restriction, without judging it's benefits or limitations, does have
- an effect on how one accesses outer closures in "programming
- languages." Some, responding to this thread have pointed out that
- in C++ a base class can be accessed explicitly:
-
- class A {
- ..member..
- };
-
- class B: public A {
- .. B::member .. A::member ..
- }
-
- Likewise, I was reminding:
-
- (begin
- (define a "moo")
- (define (foo)
- (define BASE_a a) ;; nope
- (define a "bar") ;; nope
- (display a)
- )
- (foo))
-
- disclaimers: I am not making any judgements or expressing any opinions
- here, I just find such things interesting in the ways they affect
- different languages regardless of whether those languages claim to be
- object-oriented.
-
- With the same disclaimer, there are languages that have chosen the
- other path, and have traded efficiency to be more dynamic.
-
- /charles
- ==============================================================================
- Charles Thayer, Columbia University, Dept. CS, Tech-staff... my words only.
-