eclipse / mita

mita
Eclipse Public License 2.0
56 stars 20 forks source link

using string as function parameter #356

Closed boaks closed 5 years ago

boaks commented 5 years ago
fn message(value : float, name : string)  {
   var payload = new string(255);
   payload = `{ `;
   payload += name;
   payload += ` : ${value} }`;

    println(`JSON ${payload}`);
}

reports an error

Cannot determine size of element: Cannot infer size of "FunctionParameterDeclarationImpl" of type "string".

So, with this magic "infer", how could strings be used as function argument as stated in

types - string

This is not how we think of strings nowadays. In Mita strings are first-class citizens, meaning that they feel like strings on other languages. You can simply initialize a variable with them, append them, pass them to a function and return them from one.

wegendt-bosch commented 5 years ago

This is very very likely fixed in master. Feel free to reopen if you try it and it doesn't work.

Note that your second line will be written like this in the future:

var payload: string<255>;