
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
45 lines
860 B
Plaintext
45 lines
860 B
Plaintext
== Why is this an issue?
|
|
|
|
The local variables in a ``++Static++`` ``++Sub++`` or ``++Function++`` are preserved between calls (meaning that these variables have the same lifetime as the owning module of their procedure). Static procedures should be avoided because they are difficult to test, and can result in unexpected behavior.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,vb6]
|
|
----
|
|
Private Static Function Foo() As Single
|
|
Dim val As Single ' val retains its value between invocations
|
|
|
|
val = val + 1
|
|
Foo = val
|
|
|
|
End Function
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,vb6]
|
|
----
|
|
Private Function Foo() As Single
|
|
Dim val As Single
|
|
|
|
val = val + 1
|
|
Foo = val
|
|
|
|
End Function
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Remove the static keyword
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|