Why cant a primitive datatype as parameter not changed directly?

1
Hi I am wondering why a primitive datatype (string, int, decimal,..) can't change directly in a sub mf, when giving it to as a parameter? You always have to duplicate the value by cloning it into an another variable to return a changed value of the parameter. I would expect that like in Java these parameters could changed directly in the submf/method. Is there a certain design limitation behind Mendix (complexity, security, data duplication) ? 
asked
3 answers
2

For my oppinion it is a design descision of Mendix to not manopulate a Parameter. From my perspective I the decision.

answered
2

This is so because Mendix apparently passes the parameters ‘by reference’ as opposed to ‘by value’. In regular programming languages you can change values of by-reference parameters, but you shouldn't because you would change the value of the parameter in the calling scope implicitly. Mendix therefor has made this choice to prevent this bad practice from happening, which is a good thing. Why they have not chosen to just pass the parameters by value, I am not sure. Maybe because it only requires a pointer, whilst by value requires a copy.

answered
1

This is indeed a design decision, and a good one at that. The idea that you should not change input parameters is not something that is up for debate, it is an accepted practice in most modern languages.

@Sinan I do not get your argument “while objects are allowed”. I have never been able to re-assign a variable representing an Object in Mendix ever.

answered