@@ -12,7 +12,8 @@ class Hello(Builtin):
1212 <dd>An example function in a Python-importable Mathics3 module.
1313 </dl>
1414
15- >> PyMathics`Hello["World"]
15+ >> Hello["everyone"]
16+ = "Hello, everyone!"
1617
1718 See also the <url>
1819 :developer guide section:
@@ -26,6 +27,10 @@ class Hello(Builtin):
2627 = Hello, rocky!
2728 """
2829
30+ # Set checking that the number of arguments required is zero or one.
31+ # eval_error = Builtin.generic_argument_error
32+ # expected_args = (0, 1)
33+
2934 summary_text = """classic "hello" demo"""
3035
3136 # The function below should start with "apply"
@@ -34,9 +39,15 @@ def eval(self, evaluation: Evaluation):
3439 return String ("Hello, World!" )
3540
3641 # The function below should start with "eval"
37- def eval_with_name (self , person : String , evaluation : Evaluation ) -> String :
38- "Hello[person_String ]"
39- # The above pattern matches Hello with a single string argument.
42+ def eval_with_name (self , person , evaluation : Evaluation ) -> String :
43+ "Hello[person_ ]"
44+ # The above pattern matches Hello with a argument.
4045 # See https://reference.wolfram.com/language/tutorial/Patterns.html#7301
4146 # and https://reference.wolfram.com/language/ref/Cases.html
47+
48+ # Check that "person" is a String.
49+ if not isinstance (person , String ):
50+ evaluation .message ("Hello" , "string" )
51+ return
52+
4253 return String (f"Hello, { person .value } !" )
0 commit comments