LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2004, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 16 Feb 2004 16:28:05 -0500
Reply-To:   "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Chang Y. Chung" <chang_y_chung@HOTMAIL.COM>
Subject:   Re: macro quoting in parameter defaults
Comments:   To: Jack Hamilton <JackHamilton@FIRSTHEALTH.COM>

On Mon, 16 Feb 2004 13:32:13 -0700, Jack Hamilton <JackHamilton@FIRSTHEALTH.COM> wrote:

>"Chang Y. Chung" <chang_y_chung@HOTMAIL.COM> wrote: > >>(1) in both the case, it is critical to check if study is empty. >Since >>when it is empty, you get a stransge value for outfile, also -- I >think >>this means that study is a required parameter. Consider making it >>positional also. > >Why so? > >I used to use positional parameters, and now I almost never do if >there's more than one parameter. Named parameters give a clue what the >parameters are trying to do.

Hi, Jack,

You are absolutely correct. There is no reason not to stick to named parameters only -- I agree with you.

Having said that, let me try to defend the opinion, if I may. I just thought, in some cases, the code reads better if you make required parameters as positional parameters. For example, if you are writing a macro called %sortBy(by=, options=), I just thought it would be nicer to be able to write:

%sortBy(VarA),

instead of the following which is kinds of redundant,

%sortBy(by=VarA).

Besides, you can do %sortBy(by=Vara), if you want to, even when the "by" is a positional parameter.

The key is that if a macro parameter is required, then the parameter value should be such a critical one that the macro name itself should give intuitive enough clue about what is required. And if so, then we may get a code that is, in fact, more easily understood by humans.

But, again, I guess what is "intuitive" depends, so it may be better to stick to a simpler (and better) coding style. On top of it, I have no doubt about your experience and wisdom. So, ... I have no problem writing macros without positional parameters :-)

Cheers, Chang


Back to: Top of message | Previous page | Main SAS-L page