Hacker News new | past | comments | ask | show | jobs | submit login

Hi everyone! For those who don't know us, ArkScript is a programming language made in C++ to be easily used in projects, inspired by Lisp. The language aims to be small to avoid a collection of 100 keywords with very rare/specific ones. A small set of instructions (imo) is better for productivity and to get to the point without digging in documentation for hours (even though there are only 10, you don't have to reinvent the wheel). I'm truly excited about this one, a 2 years old issue, 3 month of discussion with the dev team, and a few days only to implement it and it's even better than what I thought it would be capable of. The thing is that we planned if macros (compile time if, working only on/with other macros), constant macros (compile time values) and function macros (code modification at compile time, with arguments). Constants can hold anything, from simple values (numbers, strings) to complete blocs (a complete if, while, whatever you want), functions can take from 0 to a (nearly) infinite number of arguments through a "variadic" notation (I couldn't find a better name): ...args. The current implementation only allows macros in the scope they were defined in and in the child scopes, also macros can not be nested except for if macros, which can old any other macros and be used anywhere. This means that we can do this: !{if (= VAR 12) !{foo (bar ...args) (print bar (len args))}} Where it get interesting is that we can do this also, and everything is still resolved at compile time: !{_> (first ...args) {!{if (> (len args) 0)((_> ...args) first)first}}} (yes I named our version of the threading macro _> for now, because our parser won't allow it otherwise, -> is forbidden) And I haven't planned that the implementation nor the specification would do that (not that it specifically forbidden it either), which is a great suprise!

TL;DR: our language now has macros, and they can do even more than what we designed them for, and that's cool to play with




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: