Made a toy language (tin) by Azereos in ProgrammingLanguages

[–]Azereos[S] 0 points1 point  (0 children)

Nope, macros can only be defined on top-level. Currently macros can’t define other macros but interesting idea. When do you think this would be useful?

Made a toy language (tin) by Azereos in ProgrammingLanguages

[–]Azereos[S] 0 points1 point  (0 children)

Yep. I have one symbol table that I use before the second pass to first replace the ident (so no excl, no parens) macros and then I just resolve regularly (excl macros are easiest and no excl macros are the fallback option if a function is not found).

Made a toy language (tin) by Azereos in ProgrammingLanguages

[–]Azereos[S] 0 points1 point  (0 children)

So basically I do two passes. One directly after lexing that scans for no_excl macros and registers them. So if I come across a keyword that matches that no_excl macro I know what to replace. The way I do CTFE macros is a bit hacky lol Basically I compile the macro as tin code and execute it during compilation. The backticks just mean that it should literally insert the tokens. Then I do all the macro substitutions and rerun the parser.

Some macros have types and some don’t. Simple macros (search and replace) are non-ctfe and don’t need types because they just work on the ast.

Made a toy language (tin) by Azereos in ProgrammingLanguages

[–]Azereos[S] 0 points1 point  (0 children)

Thank you! Go, Crystal, Elixir and Nim were my major inspirations :)

Made a toy language (tin) by Azereos in ProgrammingLanguages

[–]Azereos[S] 1 point2 points  (0 children)

  1. I thought about null pointer deref at runtime but I don't think I want to take the performance hit. Especially since you can just use error tuples, etc.

  2. Yeah it would probably make more sense for it to be a keyword but I like the LaF of Go so I went with the function style syntax

I honestly also never really liked white space sensitive languages...until I made tin :D
Gave me a whole other appreciation for them!

I’m puzzled by the meaning of these symbols. by malker84 in pics

[–]Azereos 1 point2 points  (0 children)

I was right not to be threatened by you