HEADS-project / forum

Open technical discussions within the HEADS project
0 stars 0 forks source link

Array as ThingML datatype #20

Closed kehusa closed 9 years ago

kehusa commented 9 years ago

Do you have any example on how we can use arrays as datatypes in messages?

brice-morin commented 9 years ago

Yes:

message m(b : Byte[256]);

Note that you have to specify the size of the array in the message (ThingML first targeted embedded systems where we do not like dynamic allocation, etc). However, in Java/JS, this should not be a limitation (the array can be any size in practice). In C, I am not sure array works in messages.

sdalgard commented 9 years ago

Hi, In the old version of ThingML the use of arrays had unwanted sideeffects. When sending an array as parameter only the pointer to the array was added to the message. The result was that this only is safe for constant arrays.

I dont know if this is fixed in the new version...

brice-morin commented 9 years ago

it is indeed (and still) not recommended in C. But it should not have those side effects in Java and JS as we went for different choices regarding the code we generate for those platforms.

brice-morin commented 9 years ago

@kehusa I guess we can close that issue for now? Just re-open it if you have problems using array in JS (I guess you wanted to use them in JS?)