Is this possible like in C ?
Mailing lists / fpc-pascal / 2011-05
Global static vars in a procedure or function
7 messages · 2 people ·
- RRainer Stratmann 4
- JJonas Maebe 3
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Rainer Stratmann wroteIs this possible like in C ?
A typed constant declared inside a procedure/function will behave like that.
Jonas
Jonas Maebe wrote 5 lines
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
Rainer Stratmann wrote 7 lines
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
Jonas Maebe wrote 17 lines
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
Rainer Stratmann wrote 9 lines
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
Jonas Maebe wroteIf 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
