Hi Statalist. I just noticed an unexpected downside of "*" in -syntax- when writing programs. Consider this example
Because of the * in the syntax, Stata is not returning an invalid syntax error for mytest, norm(abc) even though it is not the right syntax because norm should be a string.
Instead, it is using the default value for norm and passing the incorrectly-syntaxed norm(abc) option as an extra option in `options`.
This means that Stata is not properly checking for syntax errors if the "*" option is used.
Is this expected behavior? How can I modify the program above so it checks syntax while retaining the functionality of passing additional options?
Thank you,
Code:
program define mytest syntax, [norm(integer -1 ) *] di "`norm'" di "`options'" end mytest, norm(-1) mytest, norm(abc)
Instead, it is using the default value for norm and passing the incorrectly-syntaxed norm(abc) option as an extra option in `options`.
This means that Stata is not properly checking for syntax errors if the "*" option is used.
Is this expected behavior? How can I modify the program above so it checks syntax while retaining the functionality of passing additional options?
Thank you,
Comment