~rabbits/uxn

1

Uxntal Macros Preprocessor

Details
Message ID
<cf45df06-c866-4909-9a6d-aef54083f986@100r.co>
DKIM signature
pass
Download raw message
Hi everyone,

It has been a while since I made a post to the mailing list, as things 
have been settling down(at last, some shouted in the distance), I hardly 
have to come here like "hey! new breaking change!". Don't worry, I'm not 
about to say that today either.

I guess the last large change was allowing the extension of scopes to 
allow connecting buffers to uxntal objects, which wasn't really a 
breaking change, but an extension to the assembler which kept 
past-compatibility.

https://wiki.xxiivv.com/site/uxntal_scope

FIRST CHANGE

What I'm suggesting today is in that same order of idea. It's not a 
breaking change, nobody will likely notice that it has even changed, but 
some might be happy to make use of it.

Basically,
I'm thinking about allowing macros to be declared later.

Right now if your macro is not at the top of the file, expansion will 
fail. It's not quite like a label, which allow to jump further down the 
file.

That means that code can be organized a bit nicerly-like, so macros used 
in the reset vector can can be declared at the bottom of the file if one 
wants.

That also means that the preprocessor has to run to through the whole 
file once, collecting all the macros before starting to assemble, but 
that's just an implementation detail. I've started implementing this in 
drifblim and it hardly changes anything.

SECOND THING

I'm thinking of removing the need for macros to be within curlies. I'll 
keep supporting them for now, but it'll throw a warning saying like 
"hey, you don't need these anymore", or something. The macro definition 
will end at another macro definition or at the next label, since those 
have to be unique anyways, macros should NOT be used to declare labels.

So yeah, that's it.

Rek and I have been hard at work on our next game, and I'm thinking, 
yes, macros would be really nice in some cases so I've begun adding them 
to drifblim, and being able to swap a @definition ( a b -- c ) to a 
%definition ( a b -- c ) is just so nice that I thought I'd bring it up 
on here to have your thoughts!

In any case, have a good one :)

Dll
Details
Message ID
<73e19014-983d-4c25-9bf3-8519cb9b7a50@100r.co>
In-Reply-To
<cf45df06-c866-4909-9a6d-aef54083f986@100r.co> (view parent)
DKIM signature
pass
Download raw message
Hi!

Little update on this, it has been a month of playing around with 
look-ahead macros and in the end I don't think it's worth adding and 
documenting, it's a little nicer to be able to put macros anywhere, but 
it slows down assembly by 200% which is not nice at all.

So, I've removed the traces left over from this experiment and in its 
place, Drifblim is now from now capable of parsing macros, and I've 
improved macros error messages for uxnasm(there was a little bug where 
labels and macro names could overlap, thanks Snufkin btw)

I've also improved Left to highlight macros properly and show them in 
the sidebar, and added support for them also in Uxnfor!

Thanks for the feedback, and to have messed with the proposed feature. 
Not all of my ideas are good, actually most are bad and a good chunk of 
them worse, but through this, a lot of little improvements came about 
so.. win?

In any case, have a very nice day :)

Dll
Reply to thread Export thread (mbox)