Declaring SPECIFIC Variables?

About advanced scenes, and the Thyme scripting language used in Algodoo.

Declaring SPECIFIC Variables?

Postby Anbang11 » Sat Dec 12, 2015 1:29 pm

I thought that this question were never asked, so....

Hey, I was wondering on how to declare specific variables for this problem:
I do not want to waste 32 bits, which is the capacity of int, ranging from -2147483648 to 2147483647, for holding (for instance) gear variable from 1 to 6 (can be sufficiently stored in byte, which has 8 bits, ranging from -127 to 128). Furthermore, I can also use unsigned byte, which has equal capacity of byte (8 bits), ranging from 0 to 255.

Yes, we can declare integer, but we cannot declare byte, short, int, and (possibly) long separately.
Yes, we can declare decimals, but we cannot declare float and double separately.
Can we declare these specific variables I've stated above? If yes, how?
Is it even possible to use unsigned and signed variable? If yes, how?
When your computer has multiple cores but uses programs that only supports single core....
Image
That's Algodoo!
User avatar
Anbang11
 
Posts: 72
Joined: Sat May 09, 2015 7:46 am
Location: Earth.

Re: Declaring SPECIFIC Variables?

Postby Kilinich » Sat Dec 12, 2015 3:54 pm

Why you want it? There is no need for that. Thyme is just script language.
There are following auto-assigned-types:

integer {a := 1}
float {a := 1.0}
boolean {a := true}
string {a := "1"}
procedure {a := {1+1}}
function {a := (x) => {1+x}}
list {a := [1,"1", true, {1}]}
object {a := scene.addBox({pos := [0,0]})}

In some cases automatic type conversion works ("a" + 1) will give string "a1" in result
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Declaring SPECIFIC Variables?

Postby Anbang11 » Sun Dec 13, 2015 12:14 pm

Don't you see my problem I've wrote on the original post? What a pity having 2 billion numbers left unused just for holding small number.
When your computer has multiple cores but uses programs that only supports single core....
Image
That's Algodoo!
User avatar
Anbang11
 
Posts: 72
Joined: Sat May 09, 2015 7:46 am
Location: Earth.

Re: Declaring SPECIFIC Variables?

Postby Kilinich » Mon Dec 14, 2015 2:26 am

Anbang11 wrote:Don't you see my problem I've wrote on the original post? What a pity having 2 billion numbers left unused just for holding small number.


That economy makes sense on large scale. For typical algodoo script data few megabytes is max of what you really need. So why bothering?
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Declaring SPECIFIC Variables?

Postby Anbang11 » Mon Dec 14, 2015 8:17 am

There isn't a way to declaring specific variables? That's okay.
When your computer has multiple cores but uses programs that only supports single core....
Image
That's Algodoo!
User avatar
Anbang11
 
Posts: 72
Joined: Sat May 09, 2015 7:46 am
Location: Earth.

Re: Declaring SPECIFIC Variables?

Postby Kilinich » Mon Dec 14, 2015 9:20 am

Anbang11 wrote:There isn't a way to declaring specific variables? That's okay.


No, it's automatic from value.
Dream of Algodoo as game development engine...
User avatar
Kilinich
[Best bug reporter 2010]
 
Posts: 2098
Joined: Mon Aug 31, 2009 8:27 pm
Location: South Russia

Re: Declaring SPECIFIC Variables?

Postby FRA32 » Wed Dec 16, 2015 6:22 pm

You dont really waste "2 billion numbers", you just "waste" a few mere byte, about 30. That may seem like a lot, but now imagine this:

30 bytes...
...of about 1028^3 bytes...

Quiiite a minority.
FRA32
 
Posts: 229
Joined: Wed Dec 03, 2014 9:51 pm


Return to Thyme scripting

Who is online

Users browsing this forum: No registered users and 9 guests