Re: [cc65] ca65: Global scope specifier required in "constant expressions"??

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2011-07-06 11:14:52
On Tue, Jul 05, 2011 at 11:42:48AM -0700, Agent Friday wrote:
> The documentation (5.4 Constant Expressions) makes quite clear that
> constant expressions (as expected by the .IF directive) cannot use
> forward symbol references.  Period.

Exactly. This is the reason why you get an error. The assembler doesn't know
if this is a forward reference or not.

> To then resolve the scope of
> USE_JOYPORT as a local forward reference (which is doomed to be an
> error!!), makes no sense at all.  This prevents a natural use of a
> global symbol in favor of assuming that the user is trying to do
> something ridiculous.  I don't think that does anybody any favors.

The alternative is even worse: If the assembler would just look at symbols
already defined, the behaviour of expressions would be different depending on
the context, in which they're used. In some expressions USE_JOYPORT would
evaluate to 1 in others it would evaluate to 0. This is error prone and not
desirable.

> The fact that USE_JOYPORT appears inside the .IF is all the proof
> needed that local scope is the WRONG assumption.  Doesn't it make
> the most sense to assume that the user is doing something valid, and
> simply resolve the symbols based on what is already defined?

Actually, it does often make sense to assume that the user *didn't* do
something valid. Otherwise we wouldn't need type safety in the C compiler or
warnings in the assembler and compiler.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jul 6 11:15:08 2011

This archive was generated by hypermail 2.1.8 : 2011-07-06 11:15:14 CEST