-
-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add struct-like data structure #39
Comments
What about |
If there are plans to implement an "#include someOtherScript" like functionality, we might want to just go ahead and use JSON for struct declarations and definitons. JSON is already well definedand this way independent JSON files can contribute to our scripts flawlessly. |
I have no idea how that would fit the language at all. LoLa doesn't need "includes" in a classical sense, you can just do a Also JSON doesn't define structures, and how would that help in using structures in the language itself? |
Sorry for the confusing comment. I must have not gotten fully awake when I wrote that. Please forget the part where I mention including other files. JSON can't define anything, but it can declare objects. Here's your example but with JSON:
I'm not familiar with Zig and it's community but I'm sure there exists a good JSON Parser you can integrate into LoLa to parse JSON strings into objects. My guess is implementation would be much easier compared to rolling out your own syntax, and JSON syntax is already familiar to many developers so users could seamlessly internalize the struct declaration syntax. The only downside I see is inconsistent assignment operator characters, semicolon(:) inside the structs and equal sign(=) outside of structs. JavaScript does the same, so I guess people don't care all that about consistency. |
You are aware that LoLa already has a parser and you'd have to integrate another parser into this one, whereas a "self-rolled" parser would be a work of half an hour or so? Also using a json parser would be a bad idea because LoLa uses a different type system than json ;) Also you want to have expressions inside struct decls, otherwise it would be completly useless, as you can only ever hardcode values: var struct = [
x: GetFoo(),
y: 20 + 5 * array[3],
]; must be valid syntax, assuming we use a |
Add a new data structure that works similar to arrays, but uses names as indices instead of numbers:
alternative:
The text was updated successfully, but these errors were encountered: