Skip to content

Commit 20b4bd0

Browse files
committed
all dataflow ops now work as lvalues
1 parent e67e084 commit 20b4bd0

File tree

6 files changed

+22
-15
lines changed

6 files changed

+22
-15
lines changed

Changes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- t_quartic now exported, and with a correct inverse
88
- add %PDL::{Math,Ops}::got_complex to record whether have complex versions
99
- MatrixOps::svd now handles transpose transparently
10-
- Ops::{re,im} now work as lvalues
10+
- all ops with two-way dataflow now work as lvalues
1111

1212
2.103 2026-03-03
1313
- fix regression in *linvals so takes ndarrays as start and end again

lib/PDL/Ops.pd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,6 @@ PDL_IF_BAD(if ( \$ISBAD(complexv()) ) \$SETBAD(b()); else,)
414414
!$backcode ? () : (
415415
DefaultFlow => 1,
416416
TwoWay => 1,
417-
Lvalue => 1,
418417
BackCode => pp_line_numbers(__LINE__-1, qq{
419418
PDL_IF_BAD(if ( \$ISBAD(b()) ) \$SETBAD(complexv()); else {,)
420419
$backcode

lib/PDL/PP.pm

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,7 @@ EOF
14881488
}),
14891489
PDL::PP::Rule::Returns->new("OverloadDocValues", []),
14901490

1491+
PDL::PP::Rule::Returns::One->new('Lvalue', 'TwoWay', 'TwoWay => Lvalue'),
14911492
PDL::PP::Rule->new([qw(UsageDoc ParamDoc)],
14921493
[qw(Name Doc? SignatureObj OtherParsDefaults? ArgOrder?
14931494
OverloadDocValues InplaceDocValues ParamDesc? Lvalue? NoExport?
@@ -2013,11 +2014,11 @@ EOF
20132014
sub {make_xs_code('','',@_)}),
20142015

20152016
PDL::PP::Rule->new("VTableDef",
2016-
["VTableName","ParamStructType","RedoDimsFuncName","ReadDataFuncName",
2017-
"WriteBackDataFuncName","FreeFuncName",
2018-
"SignatureObj","HaveBroadcasting","NoPthread","Name",
2019-
"GenericTypes","IsAffineFlag","TwoWayFlag","DefaultFlowFlag",
2020-
"BadFlag"],
2017+
[qw(VTableName ParamStructType
2018+
RedoDimsFuncName ReadDataFuncName WriteBackDataFuncName FreeFuncName
2019+
SignatureObj HaveBroadcasting NoPthread Name
2020+
GenericTypes IsAffineFlag TwoWayFlag DefaultFlowFlag
2021+
BadFlag)],
20212022
sub {
20222023
my($vname,$ptype,$rdname,$rfname,$wfname,$ffname,
20232024
$sig,$havebroadcasting, $noPthreadFlag, $name, $gentypes,

lib/PDL/PP.pod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,7 @@ first argument's C<copy> method will be used.
26272627

26282628
If true, sets in the C<pdl_transvtable> (see L<PDL::Internals>) the
26292629
C<iflags> such as to inform the trans's error checks connected to dataflow.
2630+
As of 2.104, also automatically sets C<Lvalue>.
26302631

26312632
=head3 Identity
26322633

@@ -2665,6 +2666,7 @@ Example:
26652666

26662667
If present, make the operation's XS function be C<lvalue>, like
26672668
L<PDL::Slices/xchg>. Added in 2.096.
2669+
As of 2.104, automatically set if C<TwoWay>.
26682670

26692671
=head1 Appendix B: PP macros and functions
26702672

lib/PDL/Slices.pd

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ pp_def('index',
151151
HandleBad => 1,
152152
DefaultFlow => 1,
153153
TwoWay => 1,
154-
Lvalue => 1,
155154
Pars => 'a(n); indx ind(); [oca] c();',
156155
Code =>
157156
$index_init . ' $c() = $a(n => this_ind);',
@@ -167,7 +166,6 @@ pp_def('index1d',
167166
HandleBad => 1,
168167
DefaultFlow => 1,
169168
TwoWay => 1,
170-
Lvalue => 1,
171169
Pars => 'a(n); indx ind(m); [oca] c(m);',
172170
Code => pp_line_numbers(__LINE__, <<'EOF'),
173171
loop(m) %{
@@ -216,7 +214,6 @@ pp_def('index2d',
216214
HandleBad => 1,
217215
DefaultFlow => 1,
218216
TwoWay => 1,
219-
Lvalue => 1,
220217
Pars => 'a(na,nb); indx inda(); indx indb(); [oca] c();',
221218
Code =>
222219
$index2d_init . pp_line_numbers(__LINE__-1, ' $c() = $a(na => this_ind_a, nb => this_ind_b);'),
@@ -582,7 +579,6 @@ avoiding the perl argument-parsing step.
582579
EOD
583580
HandleBad => 1,
584581
TwoWay => 1,
585-
Lvalue => 1,
586582
P2Child => 1,
587583

588584
# rdim: dimensionality of each range (0 dim of index PDL)
@@ -1416,7 +1412,6 @@ EOF
14161412
pp_def('xchg',
14171413
OtherPars => 'PDL_Indx n1; PDL_Indx n2;',
14181414
TwoWay => 1,
1419-
Lvalue => 1,
14201415
P2Child => 1,
14211416
AffinePriv => 1,
14221417
EquivDimCheck =>pp_line_numbers(__LINE__, <<'EOF'),
@@ -1581,7 +1576,6 @@ EOD
15811576
pp_def('mv',
15821577
OtherPars => 'PDL_Indx n1; PDL_Indx n2;',
15831578
TwoWay => 1,
1584-
Lvalue => 1,
15851579
P2Child => 1,
15861580
AffinePriv => 1,
15871581
CHeader => <<'EOF',
@@ -1857,7 +1851,6 @@ Put some dimensions to a broadcastid.
18571851
EOD
18581852
P2Child => 1,
18591853
TwoWay => 1,
1860-
Lvalue => 1,
18611854
AffinePriv => 1,
18621855
OtherPars => "PDL_Indx id; PDL_Indx whichdims[]",
18631856
Comp => 'PDL_Indx nrealwhichdims',
@@ -1938,7 +1931,6 @@ See [TBD Doc] for details and examples.
19381931
EOD
19391932
P2Child => 1,
19401933
TwoWay => 1,
1941-
Lvalue => 1,
19421934
AffinePriv => 1,
19431935
OtherPars => 'PDL_Indx atind;',
19441936
RedoDims => pp_line_numbers(__LINE__, <<'EOF'),

t/pp_pod.t

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,19 @@ subtest a_bl => sub {
155155
ok all_seen($obj, 'foo'), 'all seen';
156156
};
157157

158+
subtest a_bt => sub {
159+
my $obj = call_pp_def(foo =>
160+
Pars => 'a(n); [o]b(n)',
161+
TwoWay => 1,
162+
);
163+
ok find_usage($obj, '$b = foo($a)'), 'function call w/ arg';
164+
ok find_usage($obj, 'foo($a, $b)'), 'all arguments given';
165+
ok find_usage($obj, '$b = $a->foo'), 'method call';
166+
ok find_usage($obj, '$a->foo($b)'), 'method call, arg';
167+
ok find_usage($obj, '$a->foo .= $data'), 'method call, twoway as lvalue';
168+
ok all_seen($obj, 'foo'), 'all seen';
169+
};
170+
158171
subtest a_b_k => sub {
159172
my $obj = call_pp_def(foo =>
160173
Pars => 'a(n); [o]b(n)',

0 commit comments

Comments
 (0)