seth at freaksw dot com wrote:
> Hardly a feature IMO. I don't see anything wrong with organizing your
> code the way the causes the error. Sure it may be more organized to
> group your declares together, but isn't that for the programmer to
Yes, but the organization implies a meaning we don't support.
The language has a rule: things defined inside a block are accessible only
inside that block, unless they are exported via Public scope. The old
compiler applied this rule inconsistently; it applied to local variables,
properties, methods, and module constants, but function constants and
Declare statements wriggled around the restriction.
One of the new compiler's goals was to simplify the language's rules and
apply them consistently. It's no good to bend the rules whenever they don't
suit us, or the language becomes unpredictable. So, when the compiler sees a
piece of code like this:
If someCondition Then
Declare Sub SomeFunction Lib "MySharedLib" ()
' Do something
It applies the block-scope rule and concludes that the Declare statement
must belong to the If-Then statement. But that can't work, because you can't
declare things inside an If-Then statement. A Declare is a declaration, and
declarations must go at the root of the function, or else we imply that they
belong to whatever block they live inside: and that's a language feature we
don't (yet) provide.
The only way out is to define Declare as a special piece of magic all its
own... but we have had enough trouble from all the special cases in the old
compiler that I really do not want to go down that road with the new one.
A searchable archive of this list is available at:
<mailto:realbasic-betas-off at lists dot realsoftware dot com>
Subscribe to the digest:
<mailto:realbasic-betas-digest at lists dot realsoftware dot com>