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

From: Agent Friday <64subnet1gmail.com>
Date: 2011-07-05 20:42:48
On Tue, Jul 5, 2011 at 1:43 AM, Uz wrote:
> On Mon, Jul 04, 2011 at 06:45:54PM -0700, Agent Friday wrote:
> > I've been getting the "constant expression expected" error where I
> > don't think I should be.  I isolated the issue to the conditional
> > assembly directive being inside a .proc scope vs. being in global
> > scope.
>
> The reason why this happens is that there may be a later symbol
> definition in local scope:
>    USE_JOYPORT = 1
>    .PROC test_irq
>    .IF USE_JOYPORT
>       ; code here
>    .ENDIF

     ; This is an error, so why would I try to do this?
>    USE_JOYPORT = 0     ; Symbol in local scope with identical name!

>    .ENDPROC
> You would expect the assembler to use the local symbol, wouldn't you?

Hmmmm... I'm going to have to go with a resounding "Absolutely not!"

The documentation (5.4 Constant Expressions) makes quite clear that
constant expressions (as expected by the .IF directive) cannot use
forward symbol references.  Period.  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 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?

Respectfully,
// Agent Friday
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jul 5 20:43:03 2011

This archive was generated by hypermail 2.1.8 : 2011-07-05 20:43:06 CEST