Author Topic: Comments  (Read 10795 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Comments
« Reply #15 on: March 08, 2006, 11:49:07 PM »
.. generally 4 spaces indent and Tab=4 Spaces
Ah... Thanks.

Forgot to mentions that I code only in Notepad.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Jürg Menzi

  • Swamp Rat
  • Posts: 599
  • Oberegg, Switzerland
Re: Comments
« Reply #16 on: March 09, 2006, 02:11:19 AM »
As you know from my samples, I use comments very rarely. A function header says more than a comment behind every line.

Just my 2¢... 8-)
A computer's human touch is its unscrupulousness!
MENZI ENGINEERING GmbH
Current A2k16... A2k24 - Start R2.18

GDF

  • Water Moccasin
  • Posts: 2081
Re: Comments
« Reply #17 on: March 09, 2006, 09:51:58 AM »
On a similar topic.........

If I can add to this a little. I carry this a step further and format my dcl code. When I first started playing around with dcl code, it was hard to follow the AutoCAD's way of dcl formatting. So I started to indent my code like a vlisp editor.

I could use a some inline commenting to the code. That is a good habit I will need to start.

Code: [Select]
/////////////////////////////////////////////////////////////////////////////////////

//To load master widgets used by Arch Program
@include "..\\ARCH.dcl"
dcl_settings :default_dcl_settings {audit_level=0;}

////////////////////////////////////////////////////////////////////////////////////

arch_program_multi_layerreactor_toggle
  :row {children_fixed_height=true; children_fixed_width=true;     
    :arch_multi {}
    :arch_curlaysetreactor {arch_curlaysetreactor;}
    :text_part {label="Leader";}
    :toggle {label="Poly"; key="poly";}
    :toggle {label="Bloc"; key="bloc";}
  }

////////////////////////////////////////////////////////////////////////////////////

ARCH_DIMS :dialog {key="set-title"; initial_focus="set-title"; width=93.3; height=21.875; 
  :row {width=33.875;
    :boxed_column {label="Control Settings"; children_fixed_width=true; children_fixed_height=true; 
      :text_part {label=" Change or Set Dimstyle";}   
      :row {children_alignment=top;
        :arch_55x55_image_252 {key="D1";}
        :arch_44x44_image_253 {key="D4";}
        :arch_44x44_image_253 {key="D3";}
        :arch_44x44_image_253 {key="D2";}
        :arch_35x35_image_15 {key="D5";}
        :arch_35x35_image_15 {key="D0";}
      }
    }
    :boxed_column {label="Dimension Commands";
      :text_part {label="  Cmd Name     Description";}
      :popup_list {key="commands-list"; width=51.5; tabs="11"; multiple_select=false;}
      :spacer {}
    }
  }
  :arch_program_multi_layerreactor_toggle {arch_program_multi_layerreactor_toggle;}

  :row {children_fixed_height=true; children_fixed_width=true;
    :column {       
      :boxed_row {label="Assoc Annotation - Ext Line Control";
        :column {children_fixed_width=true; children_fixed_height=true;
          :list_box {key="lb_notes"; width=19.5; height=8;} //label="Select Note"; height=8;
        }       
        :column {children_fixed_width=true; children_fixed_height=true;
          :row {
            :column { 
              :spacer {}
              :row {
                :toggle {key="updn";}
                :text_part {key="controlupdn"; width=6;}
              }             
              :row {           
                :toggle {key="onoff";}
                :text_part {key="controlonoff"; width=6;}   
              }           
            }
            :image {key="shpimgdims"; width=7.125; height=3.25; color=-15;}
          }       
          :edit_box {key="eb_note"; edit_width=15.5;}
          :row {children_fixed_width=true;
            :radio_button {label="Pick"; key="onoffaccept";}
            :button {label="Note"; key="dnoteaccept";}
          }
        }
      }
      :row {
        :button {label="Style"; key="dimsty"; fixed_width=true;}
        :arch_35x35_image_15 {key="dbl";}
        :arch_35x35_image_15 {key="dle";}
        :arch_35x35_image_15 {key="dimeq";}
        :arch_35x35_image_15 {key="grab";}
        :arch_35x35_image_15 {key="dimb";}
        :arch_35x35_image_15 {key="lldr";}
      }
    }
    :column {
      :boxed_column {label="Place Dimensions";       
        :row {children_fixed_height=true; children_fixed_width=true;
          :arch_65x65_image_252 {key="lin";}
          :arch_65x65_image_252 {key="qdim";}
          :arch_65x65_image_252 {key="con";}   
          :arch_65x65_image_252 {key="bas";} 
          :arch_65x65_image_252 {key="ali";} 
          :arch_65x65_image_252 {key="rot";}
        }
        :row {children_fixed_height=true; children_fixed_width=true;
          :arch_65x65_image_252 {key="cen";}
          :arch_65x65_image_252 {key="rad";}
          :arch_65x65_image_252 {key="dia";}
          :arch_65x65_image_252 {key="ang";}   
          :arch_65x65_image_252 {key="180";}   
          :arch_65x65_image_252 {key="ark";}     
        }
      }
      :row {children_fixed_height=true; children_fixed_width=true;
        :spacer {width=0.5;}       
        :column {             
          :text_part {label="Textstyle :";}
          :text_part {label="Height :";}
          :text_part {label="Dimstyle :";} 
        }           
        :column {
          :text_part {key="textinfo"; width=17.125;}
          :text_part {key="textsize"; width=17.125;}
          :arch_dsty {}
        }
        :column {
          :popup_list {key="sdimdec"; edit_width=15.5;}
          :row {
            :text_part {label="  Precision :";}
            :text_part {key="dimdec"; width=6.5;}
          }
        }
      }
    }
  }
  :arch_program_dimscale {arch_program_dimscale;}
}


Gary

Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

LE

  • Guest
Re: Comments
« Reply #18 on: March 09, 2006, 10:17:14 AM »
I like my code compact

Code: [Select]
(defun detail-enable  (/ lis_objs)
  (if (setq lis_objs
     (vlax-ldata-get
       "SYM-REACTORS"
       "DETAIL-SYMBOL"))
    (foreach sub  lis_objs
      (if (and (not (rwiz-partof (car sub)))
       (not (rwiz-partof (cadr sub)))
       (not (rwiz-partof (caddr sub))))
(detail-attach
  (car sub)
  (cadr sub)
  (caddr sub))))))

Basically is a habit, I learned that from Master Reinaldo Togores.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Comments
« Reply #19 on: March 09, 2006, 10:57:42 AM »
I like mine compact too.
I think it is what you are accustom to looking at & I think that your preferences change over time.
When I first started lisping in 2003 I benefited form excessive commenting. But now find it
somewhat annoying especially the ;_ function-closing comment. AS you get better at reading lisp the
function closing comments are only helpful in the cases where there is a large amount of code.
Like when you have 20 lines of code between the (if and the closing ) .
I think the larger the indent the less important the closing comment becomes as you can follow the
flow by looking at the indent. When the indent is only 2 spaces & 20 lines later the closing parentheses
is no longer obvious. The problem with VLIDE editor is that you get All or None in the closing comment.
I choose none & add them where I feel there will be helpful to me when I return to look at the code.
As for line comments, I still find them useful & when in doubt add them. That is for when you return
months later it helps understand the code. Let me just say that people like Michael & Kerry are VERY
fluent in the language & don't need much help in reading a chunk of new code. These folks have progressed
to the point where even this commenting gets in the way.  In there case a good explanation at the beginning
is all they need and the reading of the code, if well written, is obvious to them. I hope my assumptions
here are accurate but it is my take on the subject. I am still reading the words and phrases but at times
can read the entire sentences.

My conclusion is that you should turn off the "Auto Closing Comment" feature in VLIDE & add them sparingly.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Comments
« Reply #20 on: March 09, 2006, 11:56:17 AM »
I like my formatting tight. I like to close my statmetnts after my last process.
(if (this is true)
  (Then do this stuff)
  (multiline
    (do this)
    (and this)
    (Dont forget this)
    (now we are done)) )
I tend to leave a space before the close as shown here, and my code tends to take the form of several blocks.

I too dislike the closing statment. However, im not against them being used. I see people new to lisp using them and that just shows they are thinking the process thru so I will not say that they are bad at all. I think new people should use all the formatting that makes them see the code easier. Because thats what its all about. Them not me or you. For instance. If MP was just learning code and he asked a question to Kerry and I (Do you see how I switched the rolls here *lol*). I dont think MP should have to worry about his formating at all. I say let him be comfortable with his style. And if I help him out and he uses closing statments I will assume his formatiing when correcting his code. (Note: Unless im trying to make an obvious statement in the code or something.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Comments
« Reply #21 on: March 09, 2006, 12:14:42 PM »
I like standart formatting :-)
(if lst
  (entmakex
    (append
      (list
        '(0 . "LWPOLYLINE")
        '(100 . "AcDbEntity")
        '(100 . "AcDbPolyline")
        (cons 90 (length lst))
        '(70 . 1)
      ) ;_  list
      (mapcar '(lambda (x) (cons 10 x)) lst)
    ) ;_  append
  ) ;_  entmakex
) ;_  if

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
Re: Comments
« Reply #22 on: March 09, 2006, 01:27:56 PM »
I don't know if I'm getting crankier, crotchetier, or lazier but I can't hardly stand comments of any sort anymore.  I hate writting them, I hate reading them, and I sure as heck hate maintaining them.  I'll stop there so as not to show my bad side :-)

I tend to write it off to my own naiveté, but the controversy that is stemmed by this topic and related topics never ceases to amaze me.  In groups other than the swamp this could well lead to fisticuffs :-)

Bobby C. Jones

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Comments
« Reply #23 on: March 09, 2006, 01:41:42 PM »
> Bobby C. Jones

I like to write one long program, instead of many short...
Now for me the cursor on 7442 line.
When the bracket is closed through 500 lines, comments to me help! :-)

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
Re: Comments
« Reply #24 on: March 09, 2006, 01:47:52 PM »
I like to write one long program, instead of many short...
Now for me the cursor on 7442 line.

Holy Carp!  Seriously, or are you yankin' my chain?  I'm extremely gullible you know.

I'm sitting here writting a bit of code and getting rather nervous because my procedure is getting close to 40 lines or so.  I'm actually guessing at the number of lines; I haven't counted those things in a very long time.
« Last Edit: March 09, 2006, 01:51:21 PM by Bobby C. Jones »
Bobby C. Jones

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Comments
« Reply #25 on: March 09, 2006, 01:51:13 PM »
(foreach x lst
1
2
....
300
) ;_  foreach
Very much frequently...

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Comments
« Reply #26 on: March 09, 2006, 01:57:43 PM »
More precisely. For me many small library programs (It is less than 40 lines).
And one big, processing of the list.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: Comments
« Reply #27 on: March 09, 2006, 02:03:44 PM »
>Bobby C. Jones
Example as I work with lists...
http://www.theswamp.org/Themes/oxygen_tp/images/post/xx.gif

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: Comments
« Reply #28 on: March 09, 2006, 02:13:14 PM »
*OFF TOPIC*

ElpanovEvgeniy

Try posting the image this way:

[ i m g ] http://www.theswamp.org/Themes/oxygen_tp/images/post/xx.gif [ / i m g ]

Remove the spaces...

And you get:

Hope that helps.

*CARRY ON*
I drink beer and I know things....

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Comments
« Reply #29 on: March 09, 2006, 02:17:10 PM »
*OFF TOPIC*

ElpanovEvgeniy

Try posting the image this way:

[ i m g ] http://www.theswamp.org/Themes/oxygen_tp/images/post/xx.gif [ / i m g ]

Remove the spaces...

And you get:

Hope that helps.

*CARRY ON*
[guess]
I think he was trying to get the link to the post he did in another thread, not the picture of the paper.
 [/guess]
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.