Python from Wise Guy's Viewpoint

Duncan Booth duncan at NOSPAMrcp.co.uk
Tue Oct 21 04:24:09 EDT 2003


Alex Martelli <aleax at aleax.it> wrote in 
news:OwOkb.19485$e5.710958 at news1.tin.it:

> Yes -- which is exactly why many non-programmers would prefer the
> parentheses-less notation -- with more obvious names of course;-).
> E.g.:
> emitwarning URGENT "meltdown imminent!!!"
> DOES look nicer to non-programmers than
> emitwarning(URGENT, "meltdown imminent!!!")
> 
> Indeed, such languages as Visual Basic and Ruby do allow calling
> without parentheses, no doubt because of this "nice look" thing.

I know we are agreed that Visual Basic is fundamentally broken, but it 
might be worth pointing out the massive trap that it provides for 
programmers in the subtle difference between:

     someProcedure x

and

     someProcedure(x)

and

     call someProcedure(x)

If 'someProcedure' is a procedure taking a single reference parameter, and 
modifying that parameter, then the first and third forms will call the 
procedure and modify 'x'. The second form on the other hand will call the 
procedure and without any warning or error will simply discard the 
modifications leaving 'x' unchanged.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list