Menu

#33 Undefine for macros

open
nobody
None
5
2011-07-22
2011-07-22
Anonymous
No

I always run out of defines. :-)

It would be nice that macros especially TEXTEQU or even EQU could be zeroed out for good that after this
IFDEF IFNB would report FALSE and the EQU would not expand anymore.

Discussion

  • japheth

    japheth - 2011-07-22

    I once played with PURGE and made it truly "undefine" a macro (instead of just deleting the macro lines ), but the effect is a) incompatible and b) offers no true benefit. You can play with this "feature" on your own, there's a #define TRUEPURGE in macro.c.

     
  • Ficko

    Ficko - 2011-07-22

    " a) incompatible"

    You have quit a bit extensions to MASM already and until you maintain the -Zg switch
    I don't think is a really problem.

    "b.) offers no true benefit"

    Hoho... I would challenge that. :-)

    Anytime I am doing a "open circuit" macro pair where I have to pass equates from
    one part to the other - like a proc/endproc replacement or for/next emulator etc. where the firs part "proc,for have to pass equates to the second part endproc,next -
    I always encounter this trouble to put the usefulness a limit.

    For example you wanna have your own stackframe with macro support if you write a macro which does proc/endproc and you can't undeclare the equates then you have to give every parameter given to the proc - test0 proc param1,param2 - a new name by the next proc - test1 proc param3,param4 -

    That just one sample.

    TRUEPURGE is really I was looking for, thanks a lot.

     
  • Ficko

    Ficko - 2011-07-22

    I don't know it should be a bug report but not even the "normal" purge is working correctly if the macro has assignment consists of brackets "[".

    %echo num
    gives:[esp+4]

    PURGE num
    gives:

    Error A2209: Syntax error: [

    Looks like "num" gets expanded.

     
  • Ficko

    Ficko - 2011-07-22

    I want to write bellow "isn't working correctly"

     
  • japheth

    japheth - 2011-07-23

    > Looks like "num" gets expanded.

    Of course. PURGE is intended to be used for MACROs only.

    If you want simple texts to be undefined, you have to wrap them in macro functions:

    num macro
    exitm <[esp+4]>
    endm

    Macro function names are expanded only if they are followed by a '(', so

    PURGE num

    will work.

     
  • Ficko

    Ficko - 2011-07-23

    Thanks that works – sort of -.

    What about making TRUEPURGE to be a additional directive like INCBIN that you have the choice to use it or not but make it work such a way to be useful for macros and equates equally –by not expanding them – and the purged name will be taken out of namespace as well thus the reusability of the name is given ?

    I think that would be great. :-)

     
  • japheth

    japheth - 2011-07-25

    > I think that would be great. :-)

    I'm against a new directive for this slightly obscure feature. A syntax extension to PURGE may do as well.

    > and the purged name will be taken out of namespace as well

    Ok ... defining a text macro TE1, purging it and then define TE1 as a structure? I'm not sure this will improve readability of the code. Also, the listing will only show the LAST type of the symbol - if there is one at all.

    I'm not really convinced yet that it is worth it - but I'll take it on the "todo" list, with "not the highest" priority.

     

Log in to post a comment.