Hi Damian,

I think the use of "min" and "max" in reductions is a special case.

In all other cases they act as functions, meaning you invoke them as min(arg1, 
arg2, ...).

As you point out, there are two varieties of min/max functions: one accepting a 
type and the other accepting one or more values. The former is documented at 
the bottom of this page:

   https://chapel-lang.org/docs/latest/modules/standard/Types.html

We probably should extend that documentation to add a reference to min/max on a 
tuple type that is documented in the specification as you point out, as well as 
here:

  https://chapel-lang.org/docs/latest/builtins/internal/ChapelTuple.html

Our documentation is certainly not perfect. If you have suggestions on how to 
improve it, for example with respect to min/max, you are most welcome to open a 
pull request or a github issue.

We have been moving away from adding this kind of documentation to the language spec, in 
favor of the online documentation. The goal is to have a single place where you (the 
user) can find documentation, without having to think if it is part of the language 
specification, "standard" modules, packages, etc.

Vass

On 11/19/17 12:32 AM, Damian McGuckin wrote:

I am curious ...

The functions max and min are defined over a tuple to return a tuple of the 
same type as per page 123 of the specification. You can also do

     var x = max(int(32))

and that works. Nice. I am curious at the semantics of that.

You also have max and min appearing in reductions nicely documented in the 
specification.

However, also

     x = min ( 10, 50)

returns x == 10.

But this seems to only appear in

     https://chapel-lang.org/docs/latest/builtins/internal/UtilMisc_forDocs.html

which I found only by accident. It might be nice to stick that somewhere in the 
next revision of the specification or at least cross reference it.

In a 'reduce', max and min seem to be interpreted as operators and in other 
cases as overloaded functions. Is this true or do I just totally misunderstand 
the difference between a function/proc and an operator?

If they were operators as they appear to be in reduce you could say

     x = a min b

to yield the minimum of 'a' and 'b'.

G++ uses the extension '>?' and '<?' for max and min operators. I am mixed
about whether I like them.

Regards - Damian

Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037
Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here
Views & opinions here are mine and not those of any past or present employer

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to