Skip to content

type safe data structures - #34

Merged
omicronrex merged 4 commits into
GM82Project:mainfrom
DFelipehDEV:ds-type
Apr 3, 2026
Merged

omicronrex merged 4 commits into
GM82Project:mainfrom
DFelipehDEV:ds-type

Conversation

@DFelipehDEV

Copy link
Copy Markdown
Contributor

proposal for typesafe ds_*, being able to check the type of a ds.
im keeping this as a draft as i believe there could be some changes done and its also missing ds_bag support,
i would like opinions on these.

@skyfloogle

Copy link
Copy Markdown
Member

Interesting idea! Would prefer to use numbers that can be cleanly expressed in binary (meaning combinations of powers of 2, e.g. 1/16, 2/16, 3/16).

@omicronrex

Copy link
Copy Markdown
Member

I would probably use a unified function prefix such as dss_list_create, dss_map_create etc. for consistency. I would also prefer clean floats like Floogle suggested.

Additionally, I think ds(s)_get_type should error when the float signature from the function collection isn't present.

@DFelipehDEV

Copy link
Copy Markdown
Contributor Author

dss_ doesnt come anything to mind. what do you think of a tds_ prefix? typed data structure

@DFelipehDEV

Copy link
Copy Markdown
Contributor Author

Additionally, I think ds(s)_get_type should error when the float signature from the function collection isn't present.

i feel like returning undefined and letting the user deal with the error makes more sense

@omicronrex

Copy link
Copy Markdown
Member

dss_ doesnt come anything to mind.

I suggested dss_ for Data Structure Safe. Starting the new family without ds makes it a little too hidden IMO. I think ds_safe_ could also work.

i feel like returning undefined and letting the user deal with the error makes more sense

We don't have a true undefined value in 8.2, so returning undefined wouldn't crash anything expecting strings. Additionally, I would change the return value of the type check function to return from predefined id constants that use the float values used internally, such as ds_type_map = 0.0625.

@DFelipehDEV

Copy link
Copy Markdown
Contributor Author

i feel like this is good error handling, please check

@omicronrex

Copy link
Copy Markdown
Member

Looks good! If I would change just one thing, using exact float values allows you to perform equality checks on them so the abs(x-y)<0.001 part is unnecessary.

@DFelipehDEV

Copy link
Copy Markdown
Contributor Author

oh true, my bad lol

@DFelipehDEV

Copy link
Copy Markdown
Contributor Author

done

@DFelipehDEV
DFelipehDEV marked this pull request as ready for review April 3, 2026 12:55
@omicronrex
omicronrex merged commit e72e346 into GM82Project:main Apr 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants