@@ -208,29 +208,24 @@ InstallGlobalFunction( CapInternalInstallAdd,
208
208
without_given_weight := CurrentOperationWeight( category!. derivations_weight_list, without_given_name );
209
209
with_given_weight := CurrentOperationWeight( category!. derivations_weight_list, with_given_name );
210
210
211
- if record.is_with_given = false then
211
+ # take the weight of the currently added function into account
212
+ if record.is_with_given then
212
213
213
- if with_given_weight <= weight then
214
-
215
- category!. redirects.( without_given_name ) := true ;
216
-
217
- else
218
-
219
- category!. redirects.( without_given_name ) := false ;
220
-
221
- fi ;
214
+ with_given_weight := weight;
222
215
223
216
else
224
217
225
- if weight <= without_given_weight then
226
-
227
- category!. redirects.( without_given_name ) := true ;
228
-
229
- else
230
-
231
- category!. redirects.( without_given_name ) := false ;
232
-
233
- fi ;
218
+ without_given_weight := weight;
219
+
220
+ fi ;
221
+
222
+ if with_given_weight <= without_given_weight then
223
+
224
+ category!. redirects.( without_given_name ) := true ;
225
+
226
+ else
227
+
228
+ category!. redirects.( without_given_name ) := false ;
234
229
235
230
fi ;
236
231
@@ -579,10 +574,16 @@ InstallGlobalFunction( CapInternalInstallAdd,
579
574
580
575
end );
581
576
582
- BindGlobal( " CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATION_PAIR" , function ( without_given_name, with_given_name, object_name, with_given_arguments_names, object_arguments_positions )
583
- local without_given_arguments_names, with_given_via_without_given_function, without_given_via_with_given_function;
577
+ BindGlobal( " CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATION_PAIR" , function ( without_given_rec, with_given_rec )
578
+ local without_given_name, with_given_name, without_given_arguments_names, with_given_arguments_names, with_given_object_position, with_given_via_without_given_function, with_given_arguments_strings, without_given_via_with_given_function;
579
+
580
+ without_given_name := without_given_rec.function_name;
581
+ with_given_name := with_given_rec.function_name;
582
+
583
+ without_given_arguments_names := without_given_rec.input_arguments_names;
584
+ with_given_arguments_names := with_given_rec.input_arguments_names;
584
585
585
- without_given_arguments_names := with_given_arguments_names {[ 1 .. Length( with_given_arguments_names ) - 1 ]} ;
586
+ with_given_object_position := without_given_rec.with_given_object_position ;
586
587
587
588
with_given_via_without_given_function := EvalString( ReplacedStringViaRecord(
588
589
" " "
@@ -599,78 +600,74 @@ BindGlobal( "CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATION_PAIR", function( without
599
600
)
600
601
) );
601
602
603
+ if with_given_object_position = " Source" then
604
+
605
+ with_given_arguments_strings := Concatenation( without_given_arguments_names, [ without_given_rec.output_source_getter_string ] );
606
+
607
+ elif with_given_object_position = " Range" then
608
+
609
+ with_given_arguments_strings := Concatenation( without_given_arguments_names, [ without_given_rec.output_range_getter_string ] );
610
+
611
+ elif with_given_object_position = " both" then
612
+
613
+ with_given_arguments_strings := Concatenation(
614
+ [ without_given_arguments_names[ 1 ] ] ,
615
+ [ without_given_rec.output_source_getter_string ] ,
616
+ without_given_arguments_names{[ 2 .. Length( without_given_arguments_names ) ]} ,
617
+ [ without_given_rec.output_range_getter_string ]
618
+ );
619
+
620
+ else
621
+
622
+ Error( " this should never happen" );
623
+
624
+ fi ;
625
+
602
626
without_given_via_with_given_function := EvalString( ReplacedStringViaRecord(
603
627
" " "
604
628
function( without_given_arguments )
605
629
606
- return with_given_name( without_given_arguments, object_name( object_arguments ) );
630
+ return with_given_name( with_given_arguments );
607
631
608
632
end
609
633
" " " ,
610
634
rec (
611
635
without_given_arguments := without_given_arguments_names,
636
+ with_given_arguments := with_given_arguments_strings,
612
637
with_given_name := with_given_name,
613
- object_name := object_name,
614
- object_arguments := without_given_arguments_names{ object_arguments_positions} ,
615
638
)
616
639
) );
617
640
618
641
AddDerivationToCAP( ValueGlobal( with_given_name ),
619
- [ [ ValueGlobal( without_given_name ), 1 ] ] ,
620
642
with_given_via_without_given_function
621
- : Description := Concatenation( with_given_name, " by calling " , without_given_name, " with the last argument dropped" ) );
643
+ : Description := Concatenation( with_given_name, " by calling " , without_given_name, " with the WithGiven argument(s) dropped" ) );
622
644
623
645
AddDerivationToCAP( ValueGlobal( without_given_name ),
624
- [ [ ValueGlobal( with_given_name ), 1 ] ,
625
- [ ValueGlobal( object_name ), 1 ] ] ,
626
646
without_given_via_with_given_function
627
- : Description := Concatenation( without_given_name, " by calling " , with_given_name, " with " , object_name, " as last argument " ) );
647
+ : Description := Concatenation( without_given_name, " by calling " , with_given_name, " with the WithGiven object(s) " ) );
628
648
629
649
end );
630
650
631
651
BindGlobal( " CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATIONS" , function ( record )
632
- local recnames, current_recname, current_rec, without_given_name, with_given_name, object_name, with_given_arguments_names, object_arguments_positions ;
652
+ local recnames, current_rec, without_given_rec, with_given_rec, current_recname ;
633
653
634
654
recnames := RecNames( record );
635
655
636
656
for current_recname in recnames do
637
657
638
658
current_rec := record.(current_recname);
639
-
659
+
640
660
if current_rec.is_with_given then
641
661
642
- without_given_name := current_rec.with_given_without_given_name_pair[ 1 ] ;
643
- with_given_name := current_rec.with_given_without_given_name_pair[ 2 ] ;
644
- object_name := current_rec.with_given_object_name;
645
- with_given_arguments_names := current_rec.input_arguments_names;
646
- object_arguments_positions := record.( without_given_name ).object_arguments_positions;
662
+ without_given_rec := record.(current_rec.with_given_without_given_name_pair[ 1 ] );
663
+ with_given_rec := record.(current_rec.with_given_without_given_name_pair[ 2 ] );
647
664
648
- if record.( without_given_name ).filter_list[ 1 ] <> " category" or record.( object_name ).filter_list[ 1 ] <> " category" or record.( with_given_name ).filter_list[ 1 ] <> " category" then
649
-
650
- Display( Concatenation(
651
- " WARNING: You seem to be relying on automatically installed WithGiven derivations but the first arguments of the functions involved are not the category. " ,
652
- " The automatic WithGiven derivation will not be installed. " ,
653
- " To prevent this warning, add the category as the first argument to all functions involved. " ,
654
- " Search for `category_as_first_argument` in the documentation for more details."
655
- ) );
656
-
657
- elif Length( record.( without_given_name ).filter_list ) + 1 <> Length( record.( with_given_name ).filter_list ) then
658
-
659
- Display( Concatenation(
660
- " WARNING: You seem to be relying on automatically installed WithGiven derivations. " ,
661
- " For this, the with given method must have exactly one additional argument compared to the without given method. " ,
662
- " This is not the case, so no automatic WithGiven derivation will be installed."
663
- ) );
664
-
665
- else
666
-
667
- CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATION_PAIR( without_given_name, with_given_name, object_name, with_given_arguments_names, object_arguments_positions );
668
-
669
- fi ;
665
+ CAP_INTERNAL_INSTALL_WITH_GIVEN_DERIVATION_PAIR( without_given_rec, with_given_rec );
670
666
671
667
fi ;
672
668
673
669
od ;
670
+
674
671
end );
675
672
676
673
InstallGlobalFunction( CAP_INTERNAL_INSTALL_ADDS_FROM_RECORD,
0 commit comments