SamuraiAku / SPDX.jl

Provides for the creation, reading and writing of SPDX files in multiple file formats. Written in pure Julia.
MIT License
5 stars 1 forks source link

Update SPDX Data Types to use mutable structs with the const keyword in Julia 1.8 #16

Closed SamuraiAku closed 1 year ago

SamuraiAku commented 2 years ago

Many Data Types have a mix of mutable and immutable fields. This was done mostly to try to protect the user from themselves. This is currently implemented by having all the mutable fields in a Dict and having custom setproperty!() and getproperty()

Julia 1.8 introduces the const keyword to mutable structs, allowing for the same behavior described above. This is probably faster than the hash table lookups in a Dict.

Also the Dict is of type Any, which means it possible for a user to accidentally write the wrong data type into a location. Using the mutable struct would allow for type checking at the time of write.

When implemented it should be transparent to the rest of the code.