🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
types in scripting language
hello,
im creating my own scripting language for my game. i was wondering, in my scripting language, should i just have 32-bit integer types for variables? or would it be better to allow chars (8b), shorts(16b), and longs(32b) - what about floats? would it be worth my while to allow multiple types or simply keep one 32-bit type.
option 1) only 32-bit integers
option 2) 32-bit integers and 32-bit floats
option 3) 8b, 16b, and 32b integers
option 4) only floats
option 5) 8b, 16b, 32b integers and 32-bit floats
what do you think?
- jeremiah
inlovewithGod.com
I commonly take, and recommend, option (2), 32-bit Signed Integer and Floating-point types. But what I also recommend is keep it seamless to the scriptwriter.
In all my own math functions, I look at the input variables/values, extract the floating-point values (raise errors if they send in a "string" or "atom" type), do the math, and then check; is this result an integer?
If yes, I make the output result an integer. Otherwise, I pass back a float. Reasonably simple.
In all my own math functions, I look at the input variables/values, extract the floating-point values (raise errors if they send in a "string" or "atom" type), do the math, and then check; is this result an integer?
If yes, I make the output result an integer. Otherwise, I pass back a float. Reasonably simple.
quote: Original post by keethrus
im creating my own scripting language for my game. i was wondering, in my scripting language, should i just have 32-bit integer types for variables? or would it be better to allow chars (8b), shorts(16b), and longs(32b) - what about floats?
That is your design decision to make. Here''s a question which I''m hoping will help trigger the "right" thought processes: why does the script writer need to know how many bits are used to represent a numeric type?
I would support 4 basic types. 3 of the types are integer, floating point, and string. The 4th type depends on your language - if its object oriented the 4th type is ''class'' and if its not, the 4th type would be a ''handle'' that is passed to functions to identify an object {like handle unit; unit = GetUnitFromName("bob"); SetUnitHP(unit, 10); etc}
----------
Almost typo-ified using Extrarius'' AUTOMATIC Typo Generator, but I decided to be nice =-)
----------
Almost typo-ified using Extrarius'' AUTOMATIC Typo Generator, but I decided to be nice =-)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement