An Idea Exchange for SAS software and services

Comments
by Super User
on ‎06-03-2016 02:45 AM

Like that idea. I often would like to have an option to insert comments inline within a statement (eg an if) without losing the option to out-comment whole sections of code with /* */.

by Super User
on ‎06-03-2016 06:55 AM

Don't forget that // already has meaning within a PUT or INPUT statement:  skip 2 lines before continuing.  In its current form, your suggestion might affect many existing programs.

by Community Manager
‎06-03-2016 08:18 AM - edited ‎06-03-2016 08:18 AM

The idea appeals to me too -- as I often enter a "//" comment on a SAS program and then the color-coding editor reminds me that it doesn't make sense...  But that's more about my habit from using other programming languages, and not a desire to have line-ending comments like @ChrisNZ describes.

 

As @Astounding says, I think that this would be tricky (if not impossible) to implement due to reserved operators in the bowels of the SAS language.  Today:

 

comment This is a comment;
* so is this;
/* and of course, so is this */
%* and don't forget macro comments that get stored INSIDE the compiled macro;

I'm sure @ChrisNZ knows this, but for others: don't forget that in SAS or SAS Enterprise Guide program editor, the Ctrl+/  and Shift+Ctrl+/ keys can toggle the block-style comments (/* */) for the selected text.

 

commenting.gif

by Super User
on ‎06-03-2016 02:01 PM

Minor correction on Chris's comment for Ctrl+/ , it selects the entire line regardless of selected text.

And if the block comment does not include the entire line then Shift+Ctrl+/ does nothing.

 

One of the reasons I used the IBM EPM editor when I was programming on a OS/2 machine with version 6 was the ability to have an actual block comment, highlight sections of text in a rectangle and comment just that.

 

 

About the // for comments: I'm not sure that the saving of 2 chacters for a comment is worth the complexity of something without an ending character. * ;  comment END with ; /* */ ENDS with */ A // that has no end in the middle of code seems our of style with general SAS coding behavior.

by PROC Star
on ‎06-03-2016 09:19 PM

 

Thank you all for your interest and thoughtful comments. Smiley Happy

 

@ballardw Many languages with en ending character, including a semicolon, use // comments.

 

@Astounding Mmm good point. I forgot about these. I guess we'd need an option to disable/enable // comments.

 

@ChrisHemedinger Kudos on the animated gif! I like the dedication to good comunication. Smiley Happy

As for being tricky because of other constructs, I respectfully disagree. // tells the parser: move along nothing to see here, the end of the line is here, consider the rest of the line as empty.

by Super User
‎06-03-2016 11:43 PM - edited ‎06-04-2016 12:19 AM

I cannot see how this can be supported without massive changes to the meaning of existing code. The most obvious example is the PUT statement.  What if I have a program that wants to write multiple lines and currently uses // to insert two line breaks?

 

put 'Line one' // 'Line three';

What if you had a  macro variable with a delimited list of words separated by / and you wanted to represent a missing value?

 

%let x=a//c;
%let y=%sysfunc(tranwrd(&x,//,/./));

 

Also with this style of comment the end-of-line becomes part of the syntax of the language.  Previously that was only true for in stream data.  (What happens if you have // in your in stream data?)

 

What would happen if you used these in a macro definition? Would these comments appear when you turned on the MPRINT option?  What about inside of text sent to be processed by CALL EXECUTE commands?

 

Personally I find end of line comments hard to read and a pain in the neck to maintain. Plus by the time you get to them it is too late, you have already seen the code.  You should put the comments that explain your code before the code.  

by PROC Star
‎06-04-2016 02:45 AM - edited ‎06-04-2016 06:23 PM

Yes, Tom all good points and questions.

 

You can always write

put 'Line one' / / 'Line three';

of course but legacy is an issue,

 

>What would happen if you used these in a macro definition?

In the unlikely case this was necessary, nothing would happen
%macro foo(param1=%str(/)*       // this parameter is required

                   ,param2=%str(/)/       // this parameter is optional

                   );

 

>Would these comments appear when you turned on the MPRINT option?

Either way is fine

 

>What about inside of text sent to be processed by CALL EXECUTE commands?

As each call execute generates a line of code, the treatment would be the very same as regular lines of code, if such comments were ever generated in this context.

 

 >PS What happens if you have // in your in stream data?
The code parser doesn't look at data streams. Is /* an issue as part of the data?

 

An option to allow // comments or not, like the minoperator option which also came to allow progress while preserving compatibility, would allay these concerns.

We could also consider for example ~~ comments if // appears to be too much of an issue, but why be different?

 

 

by PROC Star
2 weeks ago

 

Just reviving this as I still would very much like this feature, and the discussion focused on the slashes (my fault for including them in the title)

 

 

If // is an issue, maybe some other characters could be used, like ## or && (followed by a space!!) or anything else that does the job.

 

 

Idea Statuses
Top Liked Authors