gpandelios@gtewis.arpa (05/06/88)
Greetings, Fellow BBoarders: I am posting this for a co-worker, although I am curious about it as well. It seems like a very simple question, something that should be resolved by the documenation, but I can't find anything about it anywhere. ----------------------------Question Follows:----------------------- Using Micropower Pascal, what is the correct syntax for declaring a variable and initializing it in the same statement? Can this be done? The documenation doesn't seem to mention this. Maybe it is only valid in certain dialects. The following are examples of the idea in other languages. What is the Pascal syntax for this? Fortran: INTEGER I /5/ !Long time since I wrote this stuff Modula-2: VAR i : INTEGER := 56; (* Looks right *) Ada: Max_Employees : integer range 0..20 := 0; -------------------------------------------------------------------- Thanks in advance for your help. You may reply either to the net or to me personally. George =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ARPAnet: GPANDELIOS@GTEWIS.ARPA US Mail: George J. Pandelios GTE Government Systems Telephone: (301) 738-8924 1700 Research Blvd Rockville, MD 20850 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 1st Law of Programming: Thou shalt not change working code! Standard Disclaimer: This opinion does not necessarily represent the viewpoint of GTE Government Systems, its employees, or its affiliated organizations.
jik@athena.mit.edu (Jonathan I. Kamens) (05/06/88)
I may be putting my foot in my mouth here, but as far as I know, standard pascal does not allow initialization of variables upon declaration. There may be implementations that allow it, but that's a pretty far-reaching straying from the standard, even worse than Turbo-Pascal's constant arrays and constant records. | "This has been a test of the emergency broadcasting -=> Jonathan I. Kamens | system. If there had been a real emergency, the MIT '91 | radio to which you are listening would have been jik@ATHENA.MIT.EDU | dissolved by the heatwave following the impact of | the first warhead."
catone@dsl.cis.upenn.edu (Tony Catone) (05/09/88)
In article <5137@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan I. Kamens) writes: > >I may be putting my foot in my mouth here, but as far as I know, >standard pascal does not allow initialization of variables upon >declaration. There may be implementations that allow it, but that's a >pretty far-reaching straying from the standard, even worse than >Turbo-Pascal's constant arrays and constant records. I assume your last comment refers to Turbo's typed constant construct. Since "typed constant" is really a misnomer for initialized variable (ignoring the fact that typed constants reside in your code rather than your data segment), what distinction are you making between Turbo's strategy and that of other implementations? - Tony catone@dsl.cis.upenn.edu catone@wharton.upenn.edu
jik@athena.mit.edu (Jonathan I. Kamens) (05/10/88)
In article <4565@super.upenn.edu> catone@dsl.cis.upenn.edu.UUCP (Tony Catone) writes: >In article <5137@bloom-beacon.MIT.EDU> jik@athena.mit.edu (Jonathan >I. Kamens) writes: >> >>[Stuff about Turbo-Pascal constant arrays and records] > >I assume your last comment refers to Turbo's typed constant construct. >Since "typed constant" is really a misnomer for initialized variable >(ignoring the fact that typed constants reside in your code rather than >your data segment), what distinction are you making between Turbo's >strategy and that of other implementations? Looking back at what I posted, I realize that you are right. I *did* put my foot in my mouth :-). If anything, the turbo typed constants are more difficult to convert into standard pascal than initialization upon declaration is. I must have been a little tired.... Jonathan Kamens, MIT '91 ---------------- "And Saint Attila raised the Holy Hand Grenade up on high saying, "Oh, Lord, Bless this, thine Holy Hand Grenade, and with it smash our enemies to tiny bits." And the Lord did grin, and the people did feast upon the lambs and steers, and goats, and orangutans, and breakfast cerals, and lima bean- Skip a bit, brother....