Typed Constants!

Post your requests and ideas on the future development of mikroPascal PRO for ARM.
Post Reply
Author
Message
corado
Posts: 399
Joined: 28 Mar 2009 11:03

Typed Constants!

#1 Post by corado » 05 May 2014 23:08

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

User avatar
marina.petrovic
Posts: 2986
Joined: 18 Apr 2013 08:11

Re: Typed Constants!

#2 Post by marina.petrovic » 06 May 2014 14:35

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

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Typed Constants!

#3 Post by Dany » 06 May 2014 14:50

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".
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)

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Typed Constants!

#4 Post by corado » 06 May 2014 15:31

Ah :-(
Turbo Pascal 7 can work with this, Free Pascal too, E-Lab PAscal too :-(

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Typed Constants!

#5 Post by corado » 26 Sep 2017 21:03

I see that Turbo Pascal 6 know this type too!
Maybe earlier Version from Pascal too..

The PAscal Standard is from teh 70' :lol: :lol: :lol: :lol:
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'!? :roll: :roll: :roll: :lol:

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: Typed Constants!

#6 Post by Dany » 27 Sep 2017 18:37

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' :lol: :lol: :lol: :lol:
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'!? :roll: :roll: :roll: :lol:
This sentence has been added in the help on the Embarcadero website:
' 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 :shock: - 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)

corado
Posts: 399
Joined: 28 Mar 2009 11:03

Re: Typed Constants!

#7 Post by corado » 27 Sep 2017 20:15

yes, you're right.
But I hope that mP does anything from this two options.

VAR i : Byte = 1;

would be nice too ;-)

Post Reply

Return to “mikroPascal PRO for ARM Wish List”