News for hackers. Stuff that matters.
Re:Show HN: Whack – A simply-designed compiled programming l... by pppaul on Sunday October 28, 2018 @05:28PM (#18323327)
would recommend looking into writing a grammar, have that generate your AST, then do some transformations on the AST to generate code. you will save a lot of time.

I recently did that for a language that i made, via instaparse. the flexibility and speed i gained was very big. my language isn't Turing complete, but it has functions, lookup tables, and some pattern matching.

Re:Show HN: Whack – A simply-designed compiled programming l... by wycliffb on Sunday October 28, 2018 @05:32PM (#18323355)
> would recommend looking into writing a grammar, have that generate your AST, then do some transformations on the AST to generate code. you will save a lot of time.

I had this thought, so I used a parser combinator (mpc) to generate the AST from the grammar and source file, then extract useful elements from the AST for codegen.

Re:Show HN: Whack – A simply-designed compiled programming l... by rurban on Monday October 29, 2018 @01:47PM (#18329473)
With mpc you can support macros, adding better macro definitions at compile-time, not just primitive cpp-style replacements. This would be definitely a game changer.
Re:Show HN: Whack – A simply-designed compiled programming l... by wycliffb on Monday October 29, 2018 @02:53PM (#18330146)
Will definitely follow up on this. Maybe we could support DSLs while at it?
Re:Show HN: Whack – A simply-designed compiled programming l... by rurban on Tuesday October 30, 2018 @11:30AM (#18337511)
Yes, a bit like perl6 grammars. Just performant.
Re:Show HN: Whack – A simply-designed compiled programming l... by lizmat on Tuesday October 30, 2018 @01:04PM (#18338829)
And immutable? Aka, you could not create a DSL that would allow you to create other DSL inside of it?