develooper Front page | perl.perl6.language | Postings from March 2005

Re: nothing

Thread Previous
From:
Rod Adams
Date:
March 21, 2005 19:57
Subject:
Re: nothing
Message ID:
423F9793.7060207@rodadams.net
Juerd wrote:

>Austin Hastings skribis 2005-03-21 15:55 (-0500):
>  
>
>>I'd like to see nothing as just an alias for {}.
>> if $expr
>> {
>>   do nothing;
>> }
>>Possibly the most clear piece of P6 code ever.
>>    
>>
>
>Dangerous, though :)
>
>    do nothing if $input =~ /\W/;
>    system "rm -- $input"; 
>
>But yes, an alias would be nice. There have been some cases where I
>wanted to explicitly state "} else { do nothing }" to make clear that it
>was not a design bug.
>
>However, the very same thing can be done with a simple comment:
>
>    } else {
>        # do nothing
>    }
>
>And that is exactly what I do.
>  
>

But you can't solve

  nothing while something();

with a comment. Well, not gracefully. Not without inline comments, at least.


There seems to be some support for just saying:

  {} while something();


I would also hope the compiler could optimize away something like:

  sub nothing () {};

-- Rod Adams

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About