New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array module review --- error on multidim array print #18262
Array module review --- error on multidim array print #18262
Conversation
David: What really made me suggest you might be good to look at this was all the work you did in the last year or two making sure that throw/catch was piped through our I/O routines appropriately. The errors Andy showed made me worry that either we or he didn't have something quite right, but I don't feel like I understand the architecture well enough to know why offhand, and I was looking for other experts to help out rather than looking into it more myself. W.r.t. the "different distributions" concern, I originally had this concern, but once I understood better where Andy's code was (in a helper used by many / most rectangular arrays), I feel less concerned about it. |
I think that ultimately the error should be propagated out of the
I would try to modify |
Is the implication that readf/writef don't throw today? For some reason, I thought we'd gotten all I/O into throwing form as part of your recent effort. [checks...] Oh wait, I'm suddenly remembering: Is it the case that:
If so, something for Andy to try to see whether I'm remembering correctly would be to try |
Thanks Brad, I was confused but just checked and it looks like the free function versions of And because this internal machinery is also used within |
The error only triggers for "print me out using Chapel syntax" formats on multidimensional arrays, and since writeln() doesn't use that format (and there's no way to cause it to that I'm aware of), I don't think it applies. Or at least I'm not expert enough in I/O to know how it would. |
I just tried this and yes, if do |
That's a little bit reassuring. But then, @dlongnecke-cray , can you remind me: If an exception occurs within a |
I think we literally just do a: /* Equivalent to ``try! stdout.writeln``. See :proc:`IO.channel.writeln` */
proc writeln(const args ...?n) {
try! stdout.writeln((...args));
} I suggested to @stonea that we just leave things as is for now, but open up a followup issue to discuss the error strategy for the standalone functions. Write now (unintentional! :D) they are arguably somewhat confusing, since using
Which suggests that they can be caught and handled, when they can't. So maybe the answer to this is to have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me assuming tests pass!
If we haven't already, let's make a followup issue to discuss:
|
@dlongnecke-cray , I've made an issue to follow up on the issue you mention: I'm spending the next few days moving across the country and even though I think this is a pretty low-risk change re: making tests fail unexpectedly, I think I'll wait until I'm "back" to merge (which is before the end of the sprint \ code freeze). |
Thanks for making that issue @stonea! I think it's fine to wait if you don't feel comfortable merging this before your move. Up to you. |
Ah, thanks. For some reason, I didn't interpret the error message as coming from a Thanks for opening the new issue @stonea (which I saw before this response). |
--- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
--- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
Also ensure we return channel style in case there's an exception called in the middle of writeThis\readThis. --- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
--- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
--- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
--- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
b391752
to
b46d1fc
Compare
--- Signed-off-by: Andy Stone <stonea@users.noreply.github.com>
This PR satisfies this issue: #18090 (Array module review followup: Investigate if we throw an exception if you try and do a "Chapel Style" print out of a multidimensional array)
Basically, we decided that since Chapel doesn't have a syntax for defining a multi-dimensional array literal we want to error out if you try and do a "Chapel style" print
In other words the following should error:
And with this PR, it now will with the following message:
@dlongnecke-cray: @bradcray suggested you might be a good person to reach out for feedback on this change, particularly in regards to how it might interact with arrays of different distributions.
Experimentally, I tried the following (with my PR changes):
And it will error out as:
As is, I think the change I've made is an improvement, I'm still a little unsatisfied with it. Specifically, because even though I'm throwing an exception it isn't propagating up to the user code. The error message might lead users to thinking that they should update their code to catch an exception, but in fact.
In fact, if I set in my environment:
export CHPL_DEVELOPER=1
and rerun the example I'll get the following:With the block distributed array I'll get this:
Should we update things so this exception can work its way to the user code? If so am I going to have to update code for all of distributions (or is there some place farther up on the callstack I could do the check before we start getting into distribution specific code).
If not it seems like I'd be better off making this an
error()
rather than an exception.Let me know your thoughts.