Hallo,
in Pascal this works..in Miropascal it doesn't work..
CONST testvalue : Byte = 5;
Begin
testvalue :=10;
end;
I think its an important Funktion!! for embeddet Programming! Typed Constants
Typed Constants!
- marina.petrovic
- Posts: 2986
- Joined: 18 Apr 2013 08:11
Re: Typed Constants!
Hi,
Please, take a look at compiler Help:
mikroPascal PRO for ARM Language Reference -> Constants.
Constant is a data whose value cannot be changed during the runtime.
Constants can be used in any expression, but cannot be assigned a new value.
Best regards,
Marina
Please, take a look at compiler Help:
mikroPascal PRO for ARM Language Reference -> Constants.
Constant is a data whose value cannot be changed during the runtime.
Constants can be used in any expression, but cannot be assigned a new value.
Best regards,
Marina
Re: Typed Constants!
A "typed" constant as asked for by Dorado is in fact an initialised variable or "writable" constant. It is indeed known by a few pascal (Delphi) compilers, but is no part of the Pascal standard.
See http://delphi.about.com/od/beginners/a/ ... t.htm?rd=1 and http://docwiki.embarcadero.com/RADStudi ... 8Delphi%29.
As one can see the possibility of writable constants is default "OFF".
See http://delphi.about.com/od/beginners/a/ ... t.htm?rd=1 and http://docwiki.embarcadero.com/RADStudi ... 8Delphi%29.
As one can see the possibility of writable constants is default "OFF".
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: Typed Constants!
Ah
Turbo Pascal 7 can work with this, Free Pascal too, E-Lab PAscal too
Turbo Pascal 7 can work with this, Free Pascal too, E-Lab PAscal too
Re: Typed Constants!
I see that Turbo Pascal 6 know this type too!
Maybe earlier Version from Pascal too..
The PAscal Standard is from teh 70'
I hope that your Idea is not to use this standard from the 70' for Pascal Versions from Today!!!
Or do you work with the C stabdard out of the 70'!?
Maybe earlier Version from Pascal too..
The PAscal Standard is from teh 70'
I hope that your Idea is not to use this standard from the 70' for Pascal Versions from Today!!!
Or do you work with the C stabdard out of the 70'!?
Re: Typed Constants!
This sentence has been added in the help on the Embarcadero website:corado wrote:I see that Turbo Pascal 6 know this type too!
Maybe earlier Version from Pascal too..
The PAscal Standard is from teh 70'
I hope that your Idea is not to use this standard from the 70' for Pascal Versions from Today!!!
Or do you work with the C stabdard out of the 70'!?
' for new applications it is recommended that you use initialized variables and compile your code in the {$J-} state.'
See http://docwiki.embarcadero.com/RADStudi ... s_(Delphi).
My personal opnion is: a 'constant' value should be constant and should not be altered by any means.
That was also the starting point when defining Pascal of course, and there is no reason what so ever to change that.
After all, a writable constant is no longer a constant.
In C about anything is allowed (and even encouraged I think), so that is no reference... Pascal on the other hand should protect the user against such things/mistakes.
In addition, website 'https://www.freepascal.org/docs-html/ref/refse10.html' says 'This is an old concept from Turbo Pascal, which has been replaced with support for initialized variables: For a detailed description, see section 4.4, page 223.',
so for me it is clear: use initialised variables instead (which by the way also do not exist in mP - and I think mP should have it -, but easy to simulate... ).
Last edited by Dany on 01 Oct 2017 11:59, edited 1 time in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)
Re: Typed Constants!
yes, you're right.
But I hope that mP does anything from this two options.
VAR i : Byte = 1;
would be nice too
But I hope that mP does anything from this two options.
VAR i : Byte = 1;
would be nice too