View previous topic :: View next topic |
Author |
Message |
Ligustah
Joined: 21 Oct 2007 Posts: 45 Location: Berlin, Germany
|
Posted: Mon Jan 21, 2008 1:53 pm Post subject: Constants in MiniD |
|
|
Hi,
Are there constants in MiniD? I can't find anything about it.
If not, think about it as a new feature
Or would it slow down everything too much?
Mfg Ligustah |
|
Back to top |
|
|
JarrettBillingsley
Joined: 20 Jun 2006 Posts: 457 Location: Pennsylvania!
|
Posted: Mon Jan 21, 2008 6:40 pm Post subject: |
|
|
There aren't, and I kind of doubt it's possible without slowing stuff down..
A constant would basically be a slot somewhere that can be assigned once and no more. A local constant might be possible, but once you start getting into scary flow control stuff the compiler starts getting awfully complex.. a global constant or a constant in an object would be a namespace field which can't be reassigned. That would imply storing not just a value but a (bool, value) tuple for every namespace item where the bool would represent the constness. Reads would skip the bool but writes would check it to ensure that it would be writeable.
Another possibility would be "symbolic constants", which would be indicated syntactically some way, such as "@name". The compiler could build up a list of symbolic constants to look up for a given module/function. Then when the module/function is loaded, it would look up those constants where they're defined and insert those values directly into the constant table of the function (where it would have reserved constant slots in advance). That seems a lot more feasible. |
|
Back to top |
|
|
Ligustah
Joined: 21 Oct 2007 Posts: 45 Location: Berlin, Germany
|
Posted: Tue Jan 22, 2008 5:17 am Post subject: |
|
|
That sounds good
A seperate constant table... Nice!
Mfg Ligustah |
|
Back to top |
|
|
|