Skip to content
This repository was archived by the owner on May 6, 2026. It is now read-only.
This repository was archived by the owner on May 6, 2026. It is now read-only.

macro preproc #12

@andrieshiemstra

Description

@andrieshiemstra

something like this

//# // define console_debug macro
//#function console_debug(line){
//#    if ($GRECO_DEBUG) {
//#        // write actually writes to js/ts code
//#        write("console.debug('"+line+"')");
//#    }
//#}
function do_stuff(){
    //#console_debug('doing stuff');
    console.log("do stuff");
}

all files are evaluated in the same context so you can define and redifine functions and variables

The code above will expand to the following if $GRECO_DEBUG = true; (running in debug mode)



function do_stuff(){
    console.debug('doing stuff');
    console.log("do stuff");
}

comments are removed, lines are preserved so line numbers still make sense

a rust util will extract all code prepended by //# and replace all others with write(line)

the whole file is then evaluated with a new write method/buffer and the output is actually used/stored/cached etc

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions