out keyword for scripting language

Started by
1 comment, last by Dog_Food 22 years, 1 month ago
Rather than adopting a pointer scheme, it is easier to just allow the output keyword in some situations. However, there are some ambiguous cases which I would like help resolving. In my scripting language, a user may specify the out keyword to indicate that the passed parameter is modifiable and affects the true variable like a reference. The confusion is that some objects like the graphics object may be modified indirectly, but it is not really changed by a called function. The output keyword makes sense to me for the integral types of int, float, etc but I don't know about reference types. For example, if I have void function( out Vector v ) does that mean I can assign a new value to the Vector object, or does it mean I can assign a new vector to the vector reference. Can I use a call on it such as normalize() which clearly modifies the vector. I am trying to make the scripting language simple, and not mandate that the programmer learn about pointers. But I am confused as to what exactly would be the proper behavior in the situation. Edited by - Dog_Food on March 22, 2002 12:04:42 PM
Advertisement
It seems to me you are dealing with the problem of how to differentiate between passing by value and passing by reference. Clearly there are advantages to both. The easiest way is to use only one. You can get away without ever using references just using temp variables. However that is not always the most elligant or logical solution.

From what you said the keyword ''out'' is being used the same way the C++ ''&'' is used.

If you don''t want to have pointers, then you can try describing the action in a more english manor
such as
void function( value variable)
void function( reference variable)
where if no -keyword is used it defaults to value.

Now of course if you have references you will be able to alter stuff you don''t want to. That is a fact in programming.
quote:Original post by Jindocai
Now of course if you have references you will be able to alter stuff you don''t want to. That is a fact in programming.


Not if you const it.
--------------------Go Stick Your Head In A Pig

This topic is closed to new replies.

Advertisement