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,4b06f8f15f01a568 X-Google-Attributes: gid103376,public From: blaak@infomatch.com (Ray Blaak) Subject: Constants vs Functions (was Re: Optimizing recursion...) Date: 1998/08/27 Message-ID: <6s43nq$m31$1@berlin.infomatch.com>#1/1 X-Deja-AN: 385338257 References: <6qfhri$gs7$1@nnrp1.dejanews.com> <35cb8058.645630787@news.ne.mediaone.net> <902934874.2099.0.nnrp-10.c246a717@news.demon.co.uk> eachus@spectre.mitre.org (Robert I. Eachus) writes: > I bring this up becuase it is one of those things that you normally >don't think of in advance, but once you see it, you use it all over >the place: > function Max_Name_Length return Positive; > ... > function Max_Name_Length return Positive is > begin return 120; end Max_Name_Length; >may seem like a lot of extra work compared to: > Max_Name_Length: constant Positive := 120; >but it limits the amount of code that may have to be changed. This is a sound suggestion, but one problem with it is that such constants tend to be used to define ranges, array sizes, etc. If it is not a constant then the static property is lost, and things like compile-time fixed-sized arrays, and constraint check elimination become difficult. Cheers, The Rhythm is around me, The Rhythm has control. Ray Blaak The Rhythm is inside me, blaak@infomatch.com The Rhythm has my soul.