chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.79k stars 421 forks source link

CG: when to require explicit return type for a required function #17227

Open vasslitvinov opened 3 years ago

vasslitvinov commented 3 years ago

Main issue: #8629

In an interface declaration, when is it OK to omit the return type of a required function? Should a generic return type be regulated by the same rules as an omitted return type?

For example:

interface IFC {
  // omitted return type
  proc fun1(...);   // ok? the return type is implicitly void?
  proc fun2(...)   // ok? the return type is implicitly void or inferred from the body?
    { ... default implementation ... }
  // generic return type
  proc fun3(...): MyGenericRecord;  // ok?
  proc fun4(...): MyGenericRecord   // ok? the concrete return type is inferred from the body?
    { ... default implementation ... }
}

The current answers to the above, implemented in #17213, are:

We may want to impose stricter rules for the return types, ex.:

lydia-duncan commented 3 years ago

I would be okay with permitting generic return types for interface functions, but it would be okay with me to start by disallowing it until we're more confident in the implementation or until requested.