#Zig+Lisp

1 messages · Page 1 of 1 (latest)

pulsar cargo
#

Hello!

I come from a Rust & Common Lisp background. One of the tricks us Lispers like to pull is making DSLs for everything - including other langs (C,JS,Python). Some lisps just compile to C.

In recent projects I've experimented with making DSLs for Rust but have found it easy to hit a wall where the complexity of the lisp-based DSL compiler outweighs the value.

Zig is appealing to me for the reasons you would expect and I'm just starting to evaluate it, but how is it as a compiler target? Has anyone tried this with much success and where should I look to learn more?

The PEG grammar makes bootstrapping a parser straight-forward, and like Go the no-macro rule is a godsend for macro programmers

shut storm
#

Honestly not very good. Zig is a language that enforces quality code; even unused variables are compile errors (as well as things that are harder to fix fortranspilers). Even Zig supports C as a compiler target, I'd probably use that.

Although I think it is proposed to add a keyword to mark a file as being auto generated that will lift a few restrictions, but not sure if that would be helpful here. No clue what the issue number is, I just remember the proposed name was thisfileisautotranslatedfromc; but that's obviously not been bikeshedded yet.

#

But honestly I'd probably be the first one to use Lisp in my Zig projects if you were to make that 😛

steady marlin
#

generating zig code is very much relegated as secondary use case to having it be human readable

#

ie unused variable errors, obligatory return values

#

and there'll probably be more restrictions coming like issuing compile errors for making a variable var when it could have provably been declared const

#

so you'd have to duplicate a lot of work in order to generate zig code that can be compiled

peak frost