On Sat, 28 Apr 2007 06:57:54 +0000, Dennis Lee Bieber wrote: > On Fri, 27 Apr 2007 22:39:25 +0200, Bjoern Schliessmann > <[EMAIL PROTECTED]> declaimed the following > in comp.lang.python: > >> Dennis Lee Bieber wrote: >> >> > And I'll probably ignore those expressions whenever I do get >> > around to 2.5+... That syntax, in my mind, just... stinks... >> > >> > HP RPL made more sense: b if c [else d] end >> >> Please explain. >> >> HP RPL: b if c [else d] end >> Python: b if c else d >> >> What's the "more sense" here? >> > You didn't take account of what b, c, and d were... > > RPL: <condition> if <truth> else <false> end > Python: <truth> if <condition> else <false> > > (RPL is a somewhat common reference to the stack based language of the > later calculators -- HP48, for instance)
I believe RPL is the official name of the language used for the HP-28 and -48 series calculators, although it doesn't appear to be in their reference manuals. The syntax as given above is actually incorrect. That appears more like Forth -- an easy mistake to make. In RPL, it is: IF <test-clause> THEN <true-clause> END IF <test-clause> THEN <true-clause> ELSE <false-clause> END Note that despite being a stack-based language, the Reverse Polish notation of RPL is loosened slightly for conditional and looping commands. The syntax above is a little misleading... in fact, IF doesn't actually do anything (but is required!), as it is the THEN that pops a flag off the stack. So long as there is a value on the stack for the THEN to pop off, it doesn't matter if it gets there before or after the IF. Hence many people preferred to write: <test-clause> IF THEN <true-clause> ELSE <false-clause> END instead. Note also that each <*-clause> can be a block of code, and is only executed if needed. Either true-clause or false-clause can be empty. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list