Movatterモバイル変換


[0]ホーム

URL:


new symbol request/idea

Carey Evanscareye at spamcop.net
Sat Apr 14 20:19:07 EDT 2001


"Pete Shinners" <shredwheat at mediaone.net> writes:> i've occasionally thought it would be a good idea for there> to be a special symbol, when found at the start of a line> means "this line has the same indentation as the previous"[...]>     glBegin(GL_LINES)>     @   glColor(r,g,b)>         glVertex(x,y,z)>         glVertex(x,y,0)>     glEnd()>> #or>>     deep_involved_code()>     something_not_quite_right()> @print 'SOME DEBUG INFO', x()>     back_to_work()This isn't consistent.  In the first case, indentation on followinglines is the same as the first line with the "@", and the "@" itselfhas the same indentation as the preceding line.  In the second, theindent before the "@" changes, and the following line has the sameindent as the preceding line.I suppose in the first case, the tokenizer could be modified toincrease the indentation level to the same as any whitespace followingthe "@", and ignore the corresponding DEDENT.  Supporting just thesecond case would be possible too, if *every* improperly indented linestarted with "@".Supporting both would require very careful specification of what wassupposed to happen, and the code to parse it would be terrifying.[...]>     prepare_code()> #    if special_case():> @        this_is_how_we_do_it()>         print 'Handled'>     code_as_normal()Assuming that you meant the print to have the same indentation as thecall to this_is_how_we_do_it(), this could be done just as easily bywriting something like:    prepare_code()    #if special_case():    if 1: # DEBUG        this_is_how_we_do_it()        print 'Handled'    code_as_normal()You could also write one of the following, depending on circumstancesand which you like best:    if 1 or special_case():    if 1: # if special_case()> anyways, the syntax is slightly unclean enough it wouldn't be> used liberally, but there's simply times i want python to just> ignore the indentation for a couple lines, and there is no way> to do it.The only case I can really see justified is your very first one, andthere's no question in my mind that it would get abused for much lessreadable code.  What *I* would like to be able to do in this case isuse some sort of macro system and write this:    gl GL_LINES:        glColor(r,g,b)        glVertex(x,y,z)        glVertex(x,y,0)like I could do in Tcl or Lisp, but I don't see that happening either.--  Carey Evanshttp://home.clear.net.nz/pages/c.evans/    "Quiet, you'll miss the humorous conclusion."


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp