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,7f4d16c4ee371eb5 X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: Why is it Called a Package? Date: 2000/04/07 Message-ID: #1/1 X-Deja-AN: 608116462 References: <38DF7F38.8D656ABD@lmtas.lmco.com> <38DFB0BC.9FF72EFC@callnetuk.com> <87u2hq857e.fsf@deneb.cygnus.argh.org> <38E2A4A4.E59E997C@research.canon.com.au> <8ckfsp$ab8$1@nnrp1.deja.com> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: nntp1.ba.best.com 955136389 219 bpr@206.184.139.136 MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-04-07T00:00:00+00:00 List-Id: On 7 Apr 2000, Hyman Rosen wrote: > Brian Rogoff writes: > > Yes, uder defined overloadings of [] is a semantic issue, but I wouldn't > > think it a good idea if () were used for functions and arrays. I don't > > like C++'s "()" overloading, only the "[]" one. > > But C++'s overloading of () allows referential transparency in template > code, which can then be written without regard to whether a functor > parameter is an object or a function. That's a very good thing. In the case of an Ada like language, I don't think C++ "functors" make that much sense, since Ada allows subprograms as generic formal parameters, and I'd hope that an Ada variant would even allow subprograms assubprogram parameters, as in Pascal. I guess you could argue that for returned functors this overloading would be useful but that's rarer. Incidentally, considering the title of the thread, we should ask why its called a "functor" in C++. Seems like an abuse of existing mathematical language. I much prefer "function object". > I could argue that [] in C++ is an extremely low-level concept which > should be used only in libraries which need to construct higher-level > abstractions, and that therefore allowing it to be overloaded is bad, > because it encourages its use. Just like in Ada, high-level C++ data > structures such as vectors should use () for indexing. I'd argue that arrays are a kind of table and having the same notation for indexing there makes more sense, no matter how the table is represented. Functions are something different, *far* more general, so I prefer to use a different notation for them. For instance it makes sense to equip tables with equality, but not functions. Well, even if it makes sense, it's really hard to check equality in the case of functions :-) -- Brian