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,d0452dbe16ac0df4 X-Google-Attributes: gid103376,public From: "Nick Roberts" Subject: Re: ObjectAda vs Gnat -- bugs Date: 1997/05/20 Message-ID: <01bc6567$02846840$LocalHost@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 242772385 References: <01bc63a9$6e4575c0$LocalHost@xhv46.dial.pipex.com> Organization: UUNet PIPEX server (post doesn't reflect views of UUNet PIPEX) Newsgroups: comp.lang.ada Date: 1997-05-20T00:00:00+00:00 List-Id: Robert Dewar wrote in article ... > Nick says > > < 'implement' enumeration literals as function calls, and then simply have it > _optimise_ the calls into immediate values (pretty near the end of the > optimisation process). > > This way, you get the overloading behaviour of enumeration literals 'for > free', and without any danger of getting it wrong (a la GNAT), and you also > get the bonus of optimising genuine parameterless functions which are > defined to return an (effectively) static value into immediate values as > well. I would argue that this is an optimisation which most compilers ought > to provide, anyway (anybody disagree?).>> > > Well you have to dig in to the front end of a compiler a bit more to see > why thiings are more complicated. The trouble is that enumeration literals > are different from functions in some important ways, for example, they > are static constants, and also they can be used as selectors in te > aggregate for an enumeration rep clause -- there are many other subtleties. > So if you tried to implement them this way, apart from the significant > inefficiency for large enumeration types, you would simply swap one set of > special cases for another. It would not help at all, and in fact I think > would likely make things much worse. We find that when you distort the > RM this way, you usually live to regret it :-) I am convinced. I need to wait for my brain to finish all its passes before emitting code :-) However, one could perhaps define a nifty little function such as: function Is_Parameterless_Function (Entity: Ada_Entity'Class) return Boolean is begin return (Entity in Ada_Function and then Parameter_Count(Ada_Subprogram(Entity)) = 0) or Entity in Ada_Enumeration_Literal; end; It may still have to be used judiciously! Nick.