[Gambas-user] Array.Sort

adamnt42 at ...626... adamnt42 at ...626...
Fri Jan 9 02:43:00 CET 2015


On Fri, 09 Jan 2015 01:12:50 +0100
Benoît Minisini <gambas at ...1...> wrote:

> Le 09/01/2015 01:09, T Lee Davidson a écrit :
> > "The empty set of parentheses is REQUIRED when sort is used as a function to return an array without the optional mode parameter"
> >
> > I don't know. Wouldn't it be more accurate to say that the parentheses are required to be able to use the function call as the object which it
> > returns; as opposed to the syntax, without the parentheses, referring to the function itself?
> >
> >
> > Lee
> 
> Why not just say that?
> 
> « You can omit the "()" at the end of a function or method call 
> statement only. If you don't understand the previous sentence, always 
> use "()" to call a function or a method. »
> 
> :-)
> 

I would have thought that the issue is "the other way up", viz:

If any class method is used as the predicate of an assignment or as the implied object of a command, then the parentheses "()" must be included, even if any or all (optional) method parameters are not specified. The parentheses "()" may be left out if the method is used purely to manipulate the internal state of the object (whether or not that method may return a value).

Examples
Consider a hypothetical class method "Negate" that inverts the value of some attribute of the object and returns that value. Thus the "()" is required for:
	SomeLocalVar = MyObject.Negate()
	Print MyObject.Negate()
but
	MyObject.Negate
is perfectly legal. In this case the value is inverted but the result is "thrown away" by the interpreter.

I cannot think of any exceptions to this.

regards
Bruce

-- 
B Bruen <adamnt42 at ...3379... (sort of)>




More information about the User mailing list