🎉 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

Started by
3 comments, last by keethrus 21 years, 4 months ago
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
Advertisement
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.
RIP GameDev.net: launched 2 unusably-broken forum engines in as many years, and now has ceased operating as a forum at all, happy to remain naught but an advertising platform with an attached social media presense, headed by a staff who by their own admission have no idea what their userbase wants or expects.Here's to the good times; shame they exist in the past.
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 find the simplest way is just that: 32b ints and floats, and strings.

KISS
daerid@gmail.com
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 =-)
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk

This topic is closed to new replies.

Advertisement