From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,99ab4bb580fc34cd X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Q: access to subprogram Date: 1996/07/28 Message-ID: #1/1 X-Deja-AN: 170609074 references: <4rb9dp$qe6@news1.delphi.com> organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-07-28T00:00:00+00:00 List-Id: In article , Brian Rogoff wrote: >I think that you posted that you like Smalltalk blocks a lot, which are >essentially just anonymous closures, right? Yes, I did post that. But it's not because they are full closures -- almost all of the uses in my code, and almost all of the uses I've seen, are the downward kind. The reason I like them is that you can do things like iterators without a lot of fuss. In Pascal, using the procedures-as-parameters method, you have to write a procedure for the body of the loop, and you have to give it a name. In Ada, using the generics method, you have to do that, and you also have to write a generic instantiation, and give *that* a name. You end up cluttering the program with useless names for things that should really be anonymous (The_Loop_Body, or Do_One_Item, or whatever). So, I like Smalltalks blocks because they are anonymous. I also like them because they are written in line. When I write a loop, I want to write the iteration stuff controlling the loop, and then I want the repeated statements to be inside the loop. The procedures-as-params solution forces a weird ordering in the code. >....I think the beauty of this >construct is that you can implement lots of features cleanly in terms of >it, like control structures. No, that merely requires downward closures. I'm still looking for an example that really makes the upward direction look wonderfully powerful. >...Also the implementation of closures on objects >seems heavy/verbose to me. True. But that's OK, unless full closures are really as powerful and commonly needed as I've heard. Also, the heavy/verbose way of doing it has an advantage -- it makes quite clear which data is going to survive the return of this procedure (by being attached to a closure), as opposed to purely "local" data. - Bob