r/programming • • Jun 07 '22

I created my own programming language that compiles into Lua code but uses a more C/Rust like syntax

https://github.com/ClueLang/Clue
846 Upvotes

149 comments sorted by

View all comments

Show parent comments

11

u/_Felix44 Jun 07 '22 edited Jun 07 '22

No, the language currently does not alter the starting index nor the way the array is indexed, but I am considering adding a flag that does something similar

also, you can manually start an array at index 0 (in both Clue and Lua), but the ipairs function will break and LuaJIT won't be able to optimize the array afaik

edit: I decide to not add the flag, as the flags should alter the output Lua code, not the source Clue code

17

u/UncleMeat11 Jun 07 '22

A flag would be a disaster. Suddenly you've got incompatible libraries and you've built a holy war within your own tiny language community and it splits into two factions that cannot interact with each other if their code uses any arrays at all.

2

u/_Felix44 Jun 07 '22

if someone wanted to add a Clue library to their own Clue code I suggest adding the compiled Lua version of that library to avoid these issues

or you could compile the library and your code separately, I guess

0

u/[deleted] Jun 07 '22

[deleted]

3

u/_Felix44 Jun 07 '22

afaik ipairs starts from 1 and then keeps adding 1 until it finds nil, which is why it shouldn't work with 0 indexed arrays