JacquesCarette / Drasil

Generate all the things (focusing on research software)
https://jacquescarette.github.io/Drasil
BSD 2-Clause "Simplified" License
136 stars 25 forks source link

Constants in Julia #3824

Open B-rando1 opened 3 days ago

B-rando1 commented 3 days ago

I discovered that in Julia, the const keyword is only allowed in the global scope and in structs. This means that local constants have to be represented as variables in Julia.

At the moment, we don't seem to have a way of differentiating local and global variables/constants in GOOL, so for now we have to treat constants like we do in Python, i.e. make them variables. If we add that differentiation (as discussed in #3821), then we should be able to add the const keyword when declaring global constants.

Declaring constants in structs may have other issues. If we a separate representation of structs in GOOL, the constants shouldn't cause any issues with that. If we decide to make classes work in Julia though, there would be difficulties. That discussion is a bit up in the air at the moment, so hopefully we can talk about it on Wednesday and see if we need to discuss this further.

It seems like constant variables shouldn't be too much of a hassle, once we get #3821 sorted out. Constants inside structs will depend on what we use structs for, so I'll defer that discussion until we have more of a consensus.

JacquesCarette commented 2 days ago