perl qstn...

Chad Perrin perrin at apotheon.com
Tue Apr 6 02:56:37 UTC 2010


On Mon, Apr 05, 2010 at 05:36:32PM +0100, RW wrote:
> 
> IMO this is a bad mistake that other languages were quite right not to
> copy - a test shouldn't come after a block of code unless it's evaluated
> after the block (as in repeat...until) 

There are more things in heav'n and earth, Horatio, than are dreamt of by
designers of eagerly evaluated prefix notation languages.

Actually, I'd think that using "unless" that way would be right up the
alley of the users of most programming languages, since "unless" is here
just being used the same way as an infix notation operator with very high
precedence.  If you want to get rigorous about it, I'd prefer this
approach:

    unless (condition) (result)

. . . where it uses strict prefix notation.  I know that some people
think postfix notation is the bee's knees because of implementation
reasons, but frankly, implementation should be something we never have to
see, in my opinion -- unless we're actually implementing it.  Computers
are for scut work; humans are for idea work.

Failing strict prefix notation, I'm okay with the way Perl and Ruby use
"unless".  This:

    (result) unless (condition)

. . . could be explained away as fitting with any of:

    1. conforming to natural language expectations, thus leaving
    implementation scut-work to the realm of the computer

    2. infix notation with very high precedence for "unless"

    3. lazy evaluation, where the (result) is not evaluated until it is
    needed, which gives the interpreter plenty of time to notice there's
    an "unless" immediately following it

Obviously, the "real" answer in the case of Ruby and Perl falls somewhere
around 1.5, but 3 is still a believable-sounding excuse, and perfectly
acceptable to me.

-- 
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20100406/6997eb2d/attachment.pgp


More information about the freebsd-questions mailing list