chapel-lang / chapel

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

Disallow rectangular arrays of non-nilable element types? #14936

Closed vasslitvinov closed 4 years ago

vasslitvinov commented 4 years ago

One way to address #13602 temporarily is to disallow arrays of non-nilable element types outright. This work was already started in #14846 and also discussed in #14367, where it applied to associative arrays and maps.

This issue is to discuss this for rectangular arrays.

One alternative to this approach is to allow a rectangular array of non-nilable elements when:

vasslitvinov commented 4 years ago

I implemented a blanket error for all arrays of non-nilable element types and got 370+ errors in a paratest with futures.

[ADDED] See my changes here.

Here are a couple of observations:

mppf commented 4 years ago

Regarding array literals of non-nilable class type, I think we shouldn't worry about getting those working this release.

Regarding list and toArray, I think it would be OK for this to result in an error this release for non-nilable types. Longer-term, I don't think that we should add other variants of toArray or change the return type. With the alternative checking strategy, it will be possible to implement with e.g. var resultQ: [1.._size] eltType?; and then at the end return resultQ:class to cast away the nilability.

bradcray commented 4 years ago

Somewhat related: In PR #15187, I added an execution-time halt in the event that an array of non-nilable classes is resized. I think of this as a stopgap until we have a compile-time solution.

bradcray commented 4 years ago

I don't think this issue (completely disallow arrays of non-nilable) is really on the table anymore, and could probably be closed. @vasslitvinov, do you agree? We've got an execution-time check now to avoid resizing arrays of non-nilable, and issue #15094 as a placeholder for moving that check from execution-time to compile-time.

vasslitvinov commented 4 years ago

It is not on the table indeed. Closing.