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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,29d8139471e3f53e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 25 Sep 2010 06:54:44 -0500 From: Brian Drummond Newsgroups: comp.lang.ada Subject: Re: Preventing type extensions Date: Sat, 25 Sep 2010 13:03:10 +0100 Reply-To: brian@shapes.demon.co.uk Message-ID: References: <81799aab-a2e8-4390-8f42-abceaa5fc032@m1g2000vbh.googlegroups.com> <5c0d7798-ba09-4bd0-a28f-f1b028cce927@y3g2000vbm.googlegroups.com> <87r5gl8tky.fsf@ludovic-brenta.org> <4C9B858C.9050208@obry.net> <877hic8asm.fsf@ludovic-brenta.org> <4c9da072$0$7692$ba4acef3@reader.news.orange.fr> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-SbCy1XUe8dwQcy1+hmmn2Y1kdW0fF6foYOIERDNa4jMZmTlOE0VIDewfuVcLO09A4rXgPUeTVv7UWlZ!LqjUYeSYNcwe7JxkhB19Qt2gmeVZbXOJiB/5oTyVcUrWnIOcglD04+BuzsA0UvHjXIe9ERqIQA3L!We4= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: g2news1.google.com comp.lang.ada:14253 Date: 2010-09-25T13:03:10+01:00 List-Id: On Sat, 25 Sep 2010 09:10:58 +0200, Pascal Obry wrote: >Ludovic, > >> I do not remember anything in Smalltalk resembling class-wide types; >> could you please send me an URL? I'm curious. > >My Smalltalk is maybe rusty but I remember about Metaclass. A side of >the class definition where a variable is a class variable shared by >every instance and where a method is a class method shared also by >every instance. This looks like class-wide variable/method applied to >some kind of class-wide type (the metaclass). > >Now, as I said my Smalltalk is rusty and I may have misremembered something. > >Pascal. My understanding (from Linn Lingo which had Smalltalk-like semantics but a more block-structured syntax) was that class variables and class methods actually applied to the class itself (or derived classes), rather than instances of those classes. Thus a Bounded_String class would have a class variable describing (and perhaps allowing you to manipulate) the upper bound of the string size - this would be used by the constructor for all Bounded_Strings. Class methods relate to the class - e.g. to get/set the class variable above, or describing properties of the class (e.g. "Integer max" = 2^31 - 1) Every class has two methods which list the "instance methods" defined for an instance of the class - one listing the methods defined for the class itself, another listing all methods in the hierarchy above it, back to Object. (possibly TMI : in Lingo it actually returns the selectors - tokens - rather than the methods themselves; finding the methods from there is trivial) "Integer instanceSelectors" (or even "2 class instanceSelectors") returns + - * / asString printedOn: asFloat and others. "Integer inheritedInstanceSelectors" returns the same plus inherited methods (obviously including "class", to support "2 class" above) There are similar methods to return the class methods: "classSelectors" and "inheritedClassSelectors". Their typical implementation is to return "instanceSelectors" on the Metaclass object (a class variable) belonging to the class itself. Thus Metaclass does not seem to be related to class-wide types, but a mechanism for implementing Class as a first-class object. Ludovic is correct on dynamic despatch. It need not be slow; (there are optimisations) but it does hide the flow of control (or abstract over it!) - Brian