Re: [cc65] Global/local labels and scopes (ca65)

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2004-01-13 08:33:40


Good morning!

On Mon, Jan 12, 2004 at 04:57:43PM +0100, Mats Andrén wrote:
> The possibility to just declare EntrypointB as Global would
> be so much easier than all that explicit naming stuff. What do you say? Am
> I simply fucked up, or is there actually some sense in this? :) Maybe it is
> actually already possible to do this, only I haven't realized how to do it
> nicely?

I see your point, and this was one of the reasons why the new release allows
access to identifiers within a scope from the outside. Older versions didn't
have this feature, scopes where closed like the scopes in Pascal. From a
technical standpoint, it wouldn't be difficult to allow placing symbols into
one of the enclosing scopes, but I would prefer not to change this now for the
following reasons:

  1. Access to local symbols from the outside is a brand new feature. Even I
     am just starting to use it. I would like to get some feedback before
     changing it again.

  2. Scopes can be nested in several layers. To make the feature consistent,
     one must be able to place a symbol in any of the enclosing scopes, so I
     would have to invent a syntax for this (scoped names come to mind).

  3. After all, it's just a convenience thing. What you want is possible, but
     needs some typing. So I think we can agree that your request is not
     really urgent.

I don't know if that suits your needs, but here is your example rewritten to
use .proc instead of .scope.:

        .proc EntryPointA
              lda #$xx
              sta MainFunction::dest
              lda #$yy
              sta MainFunction::dest+1
              jmp MainFunction
        .endproc

        .proc EntrypointB
              lda #$zz
              sta MainFunction::dest
              lda #$ww
              sta MainFunction::dest+1
              jmp MainFunction
        .endproc

        .proc MainFunction
              jsr calculatesomevalue
        dest  := *+1
              sta $ffff
              rts
        .endproc

As you can see, usage of the local label is restricted to just two places,
where it makes really sense, since EntryPointA and B are actually changing the
way, in which MainFunction works.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2004-01-13 08:34:15 CET