@@ -55,9 +55,13 @@ class Abort(Builtin):
5555 = $Aborted
5656 """
5757
58+ # Set checking that the no arguments are allowed.
59+ # eval_error = Builtin.generic_argument_error
60+ # expected_args = 0
61+
5862 summary_text = "generate an abort"
5963
60- def eval (self , evaluation : Evaluation ):
64+ def eval (self , evaluation : Evaluation ): # pylint: disable=unused-argument
6165 "Abort[]"
6266
6367 raise AbortInterrupt
@@ -78,13 +82,17 @@ class Break(Builtin):
7882 = 11
7983 """
8084
85+ # Set checking that the no arguments are allowed.
86+ # eval_error = Builtin.generic_argument_error
87+ # expected_args = 0
88+
8189 messages = {
8290 "nofwd" : "No enclosing For, While, or Do found for Break[]." ,
8391 }
8492
8593 summary_text = "exit a 'For', 'While', or 'Do' loop"
8694
87- def eval (self , evaluation : Evaluation ):
95+ def eval (self , evaluation : Evaluation ): # pylint: disable=unused-argument
8896 "Break[]"
8997
9098 raise BreakInterrupt
@@ -125,6 +133,10 @@ class Catch(Builtin):
125133
126134 attributes = A_HOLD_ALL | A_PROTECTED
127135
136+ # Set checking that the between one and three arguments are allowed.
137+ eval_error = Builtin .generic_argument_error
138+ expected_args = range (1 , 4 )
139+
128140 summary_text = "handle an exception raised by a 'Throw'"
129141
130142 def eval_expr (self , expr , evaluation ):
@@ -297,7 +309,7 @@ class Do(IterationFunction):
297309 allow_loopcontrol = True
298310 summary_text = "evaluate an expression looping over a variable"
299311
300- def get_result (self , items ):
312+ def get_result (self , _items ):
301313 return SymbolNull
302314
303315
@@ -377,15 +389,32 @@ class If(Builtin):
377389 >> If[False, a] //FullForm
378390 = Null
379391
380- You might use comments ( inside '(*' and '*)') to make the branches of 'If'
392+ You might use comments inside '(*' and '*)' to make the branches of 'If'
381393 more readable:
382394 >> If[a, (*then*) b, (*else*) c];
395+
396+
397+ Since one or more arguments to a boolean operation could be symbolic, it is\
398+ possible that an 'If' cannot be evaluated. For example:
399+
400+ >> Clear[a, b]; If [a < b, a, b]
401+ = If[a < b, a, b]
402+
403+ To handle this, 'If' takes an optional fourth parameter:
404+
405+ >> If [a < b, a, b, "I give up"]
406+ = I give up
407+
383408 """
384409
385- summary_text = "if-then-else conditional expression"
386410 # This is the WR summary: "test if a condition is true, false, or
387411 # of unknown truth value"
388412 attributes = A_HOLD_REST | A_PROTECTED
413+
414+ # Set checking that the number of arguments required between 2 and 4.
415+ eval_error = Builtin .generic_argument_error
416+ expected_args = range (2 , 5 )
417+
389418 summary_text = "test if a condition is true, false, or of unknown truth value"
390419
391420 def eval (self , condition , t , evaluation ):
@@ -429,9 +458,13 @@ class Interrupt(Builtin):
429458 = $Aborted
430459 """
431460
461+ # Set checking that the no arguments are allowed.
462+ # eval_error = Builtin.generic_argument_error
463+ # expected_args = 0
464+
432465 summary_text = "interrupt evaluation and return '$Aborted'"
433466
434- def eval (self , evaluation : Evaluation ):
467+ def eval (self , evaluation : Evaluation ): # pylint: disable=unused-argument
435468 "Interrupt[]"
436469
437470 raise AbortInterrupt
@@ -460,7 +493,7 @@ class Pause(Builtin):
460493 # Number of timeout polls per second that we perform in looking
461494 # for a timeout.
462495
463- def eval (self , n , evaluation : Evaluation ):
496+ def eval (self , n , evaluation : Evaluation ): # pylint: disable=unused-argument
464497 "Pause[n_]"
465498 try :
466499 sleep_time = valid_time_from_expression (n , evaluation )
@@ -504,7 +537,7 @@ class Return(Builtin):
504537
505538 summary_text = "return from a function"
506539
507- def eval (self , expr , evaluation : Evaluation ):
540+ def eval (self , expr , evaluation : Evaluation ): # pylint: disable=unused-argument
508541 "Return[expr_]"
509542 raise ReturnInterrupt (expr )
510543
@@ -594,17 +627,23 @@ class Throw(Builtin):
594627 = Hold[Throw[1]]
595628 """
596629
630+ # Set checking that the number of arguments required is one or two. WMA uses 1..3.
631+ eval_error = Builtin .generic_argument_error
632+ expected_args = (1 , 2 )
633+
597634 messages = {
598635 "nocatch" : "Uncaught `1` returned to top level." ,
599636 }
600637
601638 summary_text = "throw an expression to be caught by a surrounding 'Catch'"
602639
603- def eval (self , value , evaluation : Evaluation ):
640+ def eval (self , value , evaluation : Evaluation ): # pylint: disable=unused-argument
604641 "Throw[value_]"
605642 raise WLThrowInterrupt (value )
606643
607- def eval_with_tag (self , value , tag , evaluation : Evaluation ):
644+ def eval_with_tag (
645+ self , value , tag , evaluation : Evaluation
646+ ): # pylint: disable=unused-argument
608647 "Throw[value_, tag_]"
609648 raise WLThrowInterrupt (value , tag )
610649
@@ -692,11 +731,15 @@ class While(Builtin):
692731 = 3
693732 """
694733
695- summary_text = "evaluate an expression while a criterion is true"
696734 attributes = A_HOLD_ALL | A_PROTECTED
735+ # Set checking that the number of arguments required is one.
736+ eval_error = Builtin .generic_argument_error
737+ expected_args = (1 , 2 )
738+
697739 rules = {
698740 "While[test_]" : "While[test, Null]" ,
699741 }
742+ summary_text = "evaluate an expression while a criterion is true"
700743
701744 def eval (self , test , body , evaluation ):
702745 "While[test_, body_]"
0 commit comments