-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add option 'NoExport' to pp_def #534
base: master
Are you sure you want to change the base?
Conversation
I did try to say it was easy! Thank you for making this effort. However, I can't accept this specific change because it is the incorrect solution to the existing problem. The only correct solution will either:
Any acceptable change to PDL::PP keys will also feature documentation updates. Wanting the docs to be fully right is the point of this exercise, isn't it? Therefore, please update this so that it meets one of the two criteria above. |
I'm not sure I have a correct understanding of these solutions. Trying to rephrase:
Maybe I am misinterpreting something, but as I understand the alternatives as described above, I dislike both. |
All Your preference matters, but isn't directly connected to what happens with the PDL code. Convention and the reality of the last 28ish years of code carries weight and will be considered. |
This is an important detail I had missed and that changes my perception of the first solution completely. So here is a new attempt in that direction. The key modifications:
|
A somehow related issue: There is something wrong with the generated usage examples when the $result = approx_artol($got, $expected, $atol, $rtol, $result);
$result = $got->approx_artol($expected, $atol, $rtol, $result);
$C = tricpy($A, $uplo, $C);
$C = $A->tricpy($uplo, $C); Update: fixed. |
I will give more specific feedback shortly. But with all these code changes, you haven't added a single test. Therefore, the most we could say is that your changes haven't broken anything currently existing. That is not an acceptable bar to aim for with anything other than the most trivial and/or doc-only changes. And we can't even say that here, because you've pushed not just one change that fails the CI, but then a second one that fails the CI. That implies the CI results weren't checked even cursorily, because the failures happened within 3 seconds of the push. The failure message is extremely unambiguous as to what is going on (the CI config needed updating), which by a fortunate coincidence I actually did on |
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.
I think on balance that NoExport
needs adding. However, the smaller and better solution to the original problem is to add a NoExport=>1
just to re
, im
, and the _*abs
functions, since that can be used untouched as %extra
. That would then allow the removal of the pp_export_nothing
.
You've said you "dislike" making the functions near the top of PDL::Ops be exported, but I have no idea why.
lib/PDL/PP.pm
Outdated
@@ -1504,7 +1507,7 @@ EOF | |||
} elsif ($argorder) { | |||
my @allouts = grep $any_out{$_} || $outca{$_}, @args; | |||
push @argsets, map [[ @inargs[0..$_] ], \@allouts, []], | |||
($#inargs-$noptional)..$#inargs; | |||
($#inargs-$noptional)..$#inargs-1; |
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.
You've correctly identified a real problem here. But I believe this is not the right solution, and instead the final index should be calculated based on how many @allouts
there are - hardcoding a 1
happens to be correct in the existing cases, but is obviously not correct.
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.
Fixed.
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.
Need to revert this part. Though it looks strange, the original doc seems to be correct:
$result = approx_artol($got, $expected, $atol, $rtol, $result);
describes the actual behavior. A provided argument $result
is passed through.
Without ArgOrder
the behavior seems to be the same, but the generated doc differs. I think the best I can do here is leave it as-is.
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.
So you're telling me that I'm wrong about ArgOrder
(a feature I created), and that actually $result
should both be passed in and returned, and that should be documented? Please at least start with the idea that I'm correct about these things.
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.
Here is an example. Two dummy functions that differ in their definition in ArgOrder
only, result in basically different generated usages.
use PDL::PP qw(Foo::Bar Foo::Bar foobar);
pp_def(foo_1 =>
Pars => 'a(n); b(n); [o]c(n)',
OtherPars => 'int k',
ArgOrder => [qw(a b k c)],
Doc => 'OtherPars and ArgOrder',
);
pp_def(foo_2 =>
Pars => 'a(n); b(n); [o]c(n)',
OtherPars => 'int k',
Doc => 'OtherPars only',
);
pp_done;
unlink 'foobar.xs';
From foobar.pm
:
=head2 foo_1
=for sig
Signature: (a(n); b(n); [o]c(n); int k)
Types: (sbyte byte short ushort long ulong indx ulonglong longlong
float double ldouble)
=for usage
$c = foo_1($a, $b, $k);
$c = foo_1($a, $b, $k, $c); # all arguments given
$c = $a->foo_1($b, $k); # method call
$c = $a->foo_1($b, $k, $c);
=head2 foo_2
=for sig
Signature: (a(n); b(n); [o]c(n); int k)
Types: (sbyte byte short ushort long ulong indx ulonglong longlong
float double ldouble)
=for usage
$c = foo_2($a, $b, $k);
foo_2($a, $b, $c, $k); # all arguments given
$c = $a->foo_2($b, $k); # method call
$a->foo_2($b, $c, $k);
The modifications I tried so far suppressed any call to foo_1
with $c
as argument, which would be a regression.
Still commenting this issue here in this PR before I split it into separate pieces because I'm not sure it will lead to a new PR from my side.
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.
In the ArgOrder
case, what needs to happen is when the output is given as an arg, it doesn't get doc-ed as a return value. Achieving that is "a simple matter of programming" (which is often not actually simple).
lib/PDL/PP.pm
Outdated
@@ -1463,7 +1465,8 @@ EOF | |||
confess "$name error in Overload doc: !=1 output (@outs)" if @outs != 1; | |||
my @ins = $sig->names_in; | |||
my @vals = ["\$$outs[0] = ".( | |||
!$one_arg ? "\$$ins[0] $op \$$ins[1]" : | |||
!$one_arg ? |
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.
Conditional operators that are cond1 ? cond2 ? v1 : v2 : v3
are incomprehensible, therefore will not be accepted. You may notice I always use (the comments here are to explain the point, and absolutely not to be added to real code):
cond1 ? v1 : # cond1 gets a "go" at giving the answer
cond2 ? v2 : # cond2 gets a "go" at giving the answer
v3 # the default when neither condition was true
One of the benefits (added to how it's actually comprehensible) is one can insert "goes" at giving an answer anywhere, and it will be immediately obvious the order of evaluation. As a contributor, it's not instantly obvious how important maintainability (and really, comprehensibility) is, but having maintained this giant codebase for some years, it's now painfully obvious to me :-)
The above points (about conditional operators, and about comprehensibility) should almost certainly be added to a "style" section of the ::DeveloperGuide
, and it would be valuable to do so as part of this PR :-)
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.
I never thought about such a systematic use of the conditional operator. I like this approach.
Fixed.
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.
As noted in this latest go - please actually use it :-)
You fixed the cygwin build, which passes the PR checks. The new failures affect other builds, that probably need to be fixed in devops/github-actions/ci-dist/action.yml. The PR is based on the current top of the master branch. I'll incorporate your remarks, though this will take some time. Looks like I need to write a completely new test for the generated PODs and I feel this should address not only the changes I made. |
Primarily a gut feeling, especially when exporting a function that is overloaded. Then I thought "Why not?". The result on an exported
So we must not export the overloaded functions. Shall we export as much as we can or not more than required? Aside from my gut feeling I'm indifferent in this question. |
A few notes:
|
It might be (ironically) a caching issue at GitHub.
Tests are important, but this isn't there yet. Please make
Show me with test cases, because written-out Q&A is far from the best approach. Please have a look at your commits, adjusting them (e.g. squash, or splitting them up) so that each is a small, useful, final change. The actual chronology of wrestling with these things is not valuable. There is no reason to document Please add a test case that proves exporting overloaded functions causes errors. I am surprised and a bit skeptical, but in any case any such error needs to be caught in a test. |
Tried to split the PR into independent pieces, but failed. The changes are too closely related, a split is technically difficult and IMHO not helpful in terms of content. Therefore I removed the
AFAICS everything related to export is documented twice in As I'm not familiar with GitHub's workflows, one stupid question: Who shall resolve/close the review issues you opened? |
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.
In this latest form, it's causing a failure in the downstream testing. For a second time, you have updated this pull request, and not checked the CI to see what it says. Is there a reason? It seems to me that is a reasonable expectation.
I will deal with the "separate commits" part in a moment.
lib/PDL/PP.pm
Outdated
).";", [] | ||
]; | ||
push @vals, [ "$name(\$$in->inplace".( | ||
!@args ? '' : ",@{[join ',', map qq{\$$_}, @args]}" | ||
my $op = defined($ovl) ? ref($ovl) ? $ovl->[0] : $ovl : ''; |
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.
The way to do this as the "goes" thing:
!defined($ovl) ? '' : ref($ovl) ? $ovl->[0] : $ovl;
If you have two ?
with no :
in between, you're not using that style.
lib/PDL/PP.pm
Outdated
@@ -1463,7 +1465,8 @@ EOF | |||
confess "$name error in Overload doc: !=1 output (@outs)" if @outs != 1; | |||
my @ins = $sig->names_in; | |||
my @vals = ["\$$outs[0] = ".( | |||
!$one_arg ? "\$$ins[0] $op \$$ins[1]" : | |||
!$one_arg ? |
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.
As noted in this latest go - please actually use it :-)
lib/PDL/PP.pm
Outdated
@@ -1504,7 +1507,7 @@ EOF | |||
} elsif ($argorder) { | |||
my @allouts = grep $any_out{$_} || $outca{$_}, @args; | |||
push @argsets, map [[ @inargs[0..$_] ], \@allouts, []], | |||
($#inargs-$noptional)..$#inargs; | |||
($#inargs-$noptional)..$#inargs-1; |
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.
In the ArgOrder
case, what needs to happen is when the output is given as an arg, it doesn't get doc-ed as a return value. Achieving that is "a simple matter of programming" (which is often not actually simple).
The changes can easily be split up, for instance as follows:
The changes are not at all indivisible. It's not technically difficult, just requires some git branch stuff. There are tutorials. The way I would approach this would be to do a A quick note: please don't add whitespace to the
That is removing one thing that is unequivocally useful to change (since the docs as generated are currently wrong in that case). That's a pity.
Fair enough.
The GitHub interface allows you to "resolve" those things, but please don't since it's the reviewer/maintainer (here, me) who decides whether these things are actually resolved, and it's helpful to them to leave the GH interface showing that. |
Before I start a new refactoring attempt, I have some additional questions and remarks.
I cannot see any connection between the failing tests in
In other cases there is such a space in the
What shall be the result of the split: Several PRs or a single PR consisting of several commits in the way you described?
I'll take care of the
Actually, I presumed it was your part. |
For the sake of progress I made some assumptions.
Here is a revised version based on these assumptions. |
Please excuse me for being so stubborn and tedious. I become obsessed with an idea too easily.
This patch provides an option
CallFQ
topp_def
that makes function calls in the generated POD's usage section fully qualified.I was merely trying to find out if I could do that. Then it turned out it was much easier than I expected.