Non-String Indices in Kym Table Literals #24

Closed
opened 2023-07-15 16:41:21 +02:00 by kayomn · 2 comments
Owner

Number indices on table literals are not properly supported. Not only does the parser itself not have any logic for inserting variables into numeric indices, but the runtime also has poorly implemented logic that will always result in an out-of-bounds exception if native code tries to insert into them.

The proposed Ona script syntax for numeric indices in tables is as follows:

  • Table literal with numerically indexed elements only:
array_table = {0, 1, 2, 3}
  • Table literal with mixed numeric and field indexed elements.
mixed_table = {
	"world",

	greeting = "hello",

	"there",
	"everyone",
}
Number indices on table literals are not properly supported. Not only does the parser itself not have any logic for inserting variables into numeric indices, but the runtime also has poorly implemented logic that will always result in an out-of-bounds exception if native code tries to insert into them. The proposed Ona script syntax for numeric indices in tables is as follows: * Table literal with numerically indexed elements only: ```lua array_table = {0, 1, 2, 3} ``` * Table literal with mixed numeric and field indexed elements. ```lua mixed_table = { "world", greeting = "hello", "there", "everyone", } ```
kayomn added this to the (deleted) milestone 2023-07-15 16:41:21 +02:00
kayomn added the
bug
label 2023-07-15 16:41:22 +02:00
Author
Owner

In order to support symbols, similar to Ruby, I believe this issue should be expanded to also include handling for symbols.

The new syntax proposal is as follows:

  • Table literal with numerically indexed elements only:
array_table = {0, 1, 2, 3}
  • Table literal with stringly indexed elements only:
string_table = {["foo"] = "bar", ["number"] = 42}
  • Table literal with symbolically indexed elements only:
symbol_table = {.foo = "bar", .number = 42}
  • Table literal with mixed numeric and field indexed elements.
mixed_table = {
	"world",
	.greeting = "hello",
	["language"] = "en",
	[5] = "there",
	"everyone",
}
In order to support symbols, similar to Ruby, I believe this issue should be expanded to also include handling for symbols. The new syntax proposal is as follows: * Table literal with numerically indexed elements only: ```lua array_table = {0, 1, 2, 3} ``` * Table literal with stringly indexed elements only: ```lua string_table = {["foo"] = "bar", ["number"] = 42} ``` * Table literal with symbolically indexed elements only: ```lua symbol_table = {.foo = "bar", .number = 42} ``` * Table literal with mixed numeric and field indexed elements. ```lua mixed_table = { "world", .greeting = "hello", ["language"] = "en", [5] = "there", "everyone", } ```
kayomn changed title from Number Indices in Kym Table Literals to Non-String Indices in Kym Table Literals 2023-07-22 15:18:20 +02:00
Author
Owner

Re-opening as #30 didn't end up solving this issue fully, only partially with the introduction of symbol indices.

Re-opening as #30 didn't end up solving this issue fully, only partially with the introduction of symbol indices.
kayomn reopened this issue 2023-08-12 15:21:21 +02:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: kayomn/ona#24
No description provided.