Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-05

Global static vars in a procedure or function

7 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Rainer Stratmann
to Jonas Maebe
Jonas Maebe wrote 5 lines
On 09 May 2011, at 20:48, Rainer Stratmann wrote: > Is this possible like in C ? A typed constant declared inside a procedure/function will behave like that.

Ah, thanks. Does Delphi also behave like this?

I did not find it in the documentation. May be it can be added there.

http://www.freepascal.org/docs-html/ref/refse10.html http://wiki.freepascal.org/Const

Also here it is worth to mention:
http://www.freepascal.org/docs-html/ref/refse20.html#x52-590004.2

Show quoted text 5 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Rainer Stratmann
Rainer Stratmann wrote 7 lines
Am Monday 09 May 2011 20:54:42 schrieb Jonas Maebe: > On 09 May 2011, at 20:48, Rainer Stratmann wrote: >> Is this possible like in C ? > > A typed constant declared inside a procedure/function will behave like > that. Ah, thanks. Does Delphi also behave like this?

Yes.

I did not find it in the documentation. May be it can be added there. http://www.freepascal.org/docs-html/ref/refse10.html

It is mentioned there, in the remark at the bottom of the page.

Jonas

Rainer Stratmann
to Jonas Maebe
Jonas Maebe wrote 17 lines
On 09 May 2011, at 21:14, Rainer Stratmann wrote: > Am Monday 09 May 2011 20:54:42 schrieb Jonas Maebe: >> On 09 May 2011, at 20:48, Rainer Stratmann wrote: >>> Is this possible like in C ? >> >> A typed constant declared inside a procedure/function will behave like >> that. > > Ah, thanks. Does Delphi also behave like this? Yes. > I did not find it in the documentation. May be it can be added there. > > http://www.freepascal.org/docs-html/ref/refse10.html It is mentioned there, in the remark at the bottom of the page.

More exactly I mean to describe it there explicitly as a replacement of a static variable. So if someone searches for that there are not only the results that critizise pascal for the lack of static variables :-)

Like here: (2.2)
http://www.lysator.liu.se/c/bwk-on-pascal.html
And even here: (Criticism)
http://en.wikipedia.org/wiki/Pascal_(programming_language)

best regards, Rainer

Show quoted text 5 lines
Jonas _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Jonas Maebe
to Rainer Stratmann
Rainer Stratmann wrote 9 lines
Am Monday 09 May 2011 21:17:17 schrieb Jonas Maebe: > On 09 May 2011, at 21:14, Rainer Stratmann wrote: >> I did not find it in the documentation. May be it can be added there. >> >> http://www.freepascal.org/docs-html/ref/refse10.html > > It is mentioned there, in the remark at the bottom of the page. More exactly I mean to describe it there explicitly as a replacement of a static variable.

FPC/Delphi-style Pascal does not define the term "static variable" (except in the context of classes, although even there they are nowadays simply called "class variables"). The manual is not a tutorial for C programmers on how to implement equivalent functionality in Pascal. We don't do that elsewhere in the manual either.

So if someone searches for that there are not only the results that critizise pascal for the lack of static variables :-)

If people don't like a language (any language, not just one or other Pascal dialect) and want to criticise it, they will always find bad things to say. The FPC manual is not the place to get involved into such petty debates.

Jonas

Rainer Stratmann
to Jonas Maebe
Jonas Maebe wrote
If people don't like a language (any language, not just one or other Pascal dialect) and want to criticise it, they will always find bad things to say. The FPC manual is not the place to get involved into such petty debates.

I did not say or expect that. I looked at it from the point of userfriendlyness and also a little bit marketing. And from that point it is probably that someone who is searching for an appropriate programming language may has knowledge of the language 'C'. And if it is mentioned in the manual that a typed const behaves like a static var all is done. Rainer

Jonas_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal