chapel-lang / chapel

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

Idea to modify the Point of Instantiation rule (POI) #15754

Open vasslitvinov opened 4 years ago

vasslitvinov commented 4 years ago

One way to modify our current POI rule is to require users to opt into it. By default it would not apply. To opt in, provide some syntax to add to the call, for example akin to try-expressions or a keyword-like receiver.

proc aLibraryFunction(.....) {
  anotherLibraryFunction(...);
  userScope.aUserProvidedFunction(...);  // 'userScope' is a keyword like 'this'
}

Benefits:

No change:

Downside:

vasslitvinov commented 4 years ago

@mppf @bradcray @benharsh what do you think about this idea?

mppf commented 4 years ago

@vasslitvinov - I think this is an interesting idea but I would expect it to have different syntax. As you pointed out, we would need a way to make things like var x: T work. That leads my thinking to some kind of decorator for the function or some of its arguments or some kind of block statement.

However I think the main question here is this - is it the common case that unconstrained generics will need this behavior? In that case, what do we gain by requiring users to opt in (almost all the time)?