nurpax / c64jasm

C64 6502 assembler in TypeScript
51 stars 14 forks source link

[Improvement] Built-in logs with f-string like support #77

Open shazz opened 3 years ago

shazz commented 3 years ago

it would be great to have a specific logger directive which supports f-string like arguments like:

!log("Current Bank selected: {VIC.BANK} in iteration {i}")

Workaround using a plugin:

module.exports = {
    debug: ({}, args) => {
        console.log(args);
    }
}
!!utils.debug(["Current Bank selected:", VIC.BANK, "in iteration", i])
nurpax commented 3 years ago

I'm a big fan of f-strings in Python but not a big fan of implementing them. :) This was even done a bit poorly in Python, I hear they're going to use a stronger parser in upcoming Python versions to make it less annoying to deal with string quotes.

Python "print" or JS "console.log" style would be simpler. This looks like your !!utils.debug except without the list:

!! print("Current Bank selected:", VIC.BANK, "in iteration", i)

Additionally would need some helper functions like converting to hex strings.

Built-in support for this would be great because this way c64jasm could print the log prints only on the last successful pass, rather than log printing in every compile pass.