From BASIC to Julia

I have no experiences with macros but co-working with AI tools let me run this basic code:

@cls
@locate 10 10
@color 11 1
name = @input("What is your name? ")
@locate 11 10
@print("Hello, $name !")

Here is the set of macros (fill free to correct them, I am sure they are not idiomatic Julia macros):

macro cls()
    :(print("\033[2J"))
end

macro locate(row, col)
    quote
        ccol = $(esc(col))
        crow = $(esc(row))
        print("\033[$(crow);$(ccol)H")
    end
end

macro color(background, foreground)
    quote
        bc = $(esc(background))
        fc = $(esc(foreground))
        print("\033[48;5;$(bc)m")
        print("\033[38;5;$(fc)m")
    end
end

macro input(prompt)
    quote
        print($prompt)
        readline()
    end
end

macro print(str)
    quote
        cstr = $(esc(str))
        print("$cstr\n")
    end
end

with fun :slight_smile:

5 Likes