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.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,cfb2002511b830ab X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,UTF8 Received: by 10.68.36.6 with SMTP id m6mr25693716pbj.4.1322485415623; Mon, 28 Nov 2011 05:03:35 -0800 (PST) Path: lh20ni30157pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: Starter project: getopt_long in Ada Date: Mon, 28 Nov 2011 14:02:19 +0100 Organization: Ada @ Home Message-ID: References: <4ecfc4c4$0$6579$9b4e6d93@newsspool3.arcor-online.net> NNTP-Posting-Host: HPaqGWnfwIRqcDVnO+VqKA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/11.60 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:19210 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2011-11-28T14:02:19+01:00 List-Id: Le Mon, 28 Nov 2011 09:21:51 +0100, Natasha Kerensikova = a =C3=A9crit: >>> It's just that I don't like at all having a tagged type for only one= >>> dispatching operation (and no obvious need for internal state). >> If you think Specification, you should not say =E2=80=9CI=E2=80=9D he= re. > > I'm sorry, but I don't understand what you mean there. Oops, I was unclear, indeed. Rewording: a specification is probably not just intended to you, and eve= n = yourself, may behave like someone else some future day. If You (the =E2=80= =9CI=E2=80=9D = you used) don't see a need for something right now, and drop an = abstraction for this sole purpose, this may not be a good thing for your= = interface. One may think reusable and abstract when setting up an = interface, not just think about the actual needs of the moment. Question= s = like =E2=80=9Cand what if ?=E2=80=9D may be good track. As tagged type c= an to more while = still being capable of the less, compared to access to subprogram, and = nothing prevent the use of tagged types, then the idea of tagged types = should not be dropped with the argument =E2=80=9CI don't need at the mom= ent=E2=80=9D. = Otherwise, you will have to change the interface later, and its always = better to update an implementation than an interface. Sorry for the smalltalk=E2=80=A6 I guess you already know all of that (r= ed-face). > [important snip dropped to be short] >The rough design is based around an array created by the client for the= > library engine, whose elements are a record containing a lexer callbac= k > (the input-to-token part), a renderer callback (token-to-output), an > indication for engine to not keep calling every entry all the time, an= d > a priority that breaks ties. > > The engine calls the input-to-token part when adequate, which updates > the current position and returns a Token'Class object, which is then f= ed > to the corresponding token-to-output callback. > > [important snip dropped to be short] I won't comment, as I am not sure I have clear mind about it. > Maybe I'm too tainted with C++ implementation details, but what I > imagined was the access-to-subprogram containing the address of the > address of the subprogram, so that's one dereference, while a tagged > type instance would contain a reference to a dispatch table (shared by= > all instances) which itself contains a reference to the actual code. > > It feels like a waste of resources to have a one-entry dispatch table,= > but I'm not sure dealing with it optimally is really worth the extra > complexity in compilers. Both are implementation assumptions. An access type may not be = dereferenced straight away, at least with Ada which know access type lev= el = check, and an access type may as much be an index in some array, among = other things. Many time, you have to use =E2=80=9C.all=E2=80=9D with acc= ess types, and = when not there, it's there, implicitly: this =E2=80=9C.all=E2=80=9D does= not seems = warranted to me, to not involve any operation. On the other side, the sa= me = with tagged types. If a compiler know a XXX_Type'Class only has instance= = of a single known type, then it can avoid all dispatching tables, which = = are anywhere a particular implementation (as an example, SmallEiffel use= d = conditional in some case, instead of a VMT, and could even do direct cal= l = in some other more rare cases). There is no way to assume an access to = procedure is more or less efficient than what is semantically a = dispatching call. -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: [Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univer= sity]