Re: Re: limiting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 10, 2012 at 10:26 PM, Ashley Sheridan
<ash@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, 2012-10-10 at 14:53 -0400, David McGlone wrote:
>
>> On Wednesday, October 10, 2012 07:36:00 PM Tim Streater wrote:
>> > On 10 Oct 2012 at 19:17, David McGlone <david@xxxxxxxxxxxxx> wrote:
>> >
>> >
>> > >>
>> > >>
>> > >> BTW - in any of your other computer languages didn't they utilize a
>> > >> 'return' statement?  PHP's is no different.
>> > >
>> > >
>> > >
>> > > back in  like '85, I learned Pascal that's the only language I learned and
>> > > I
>>  don't recall if it used return.
>> >
>> >
>> > Mmmm. There's the problem. Pascal doesn't *have* a return statement. In
>> > Pascal, implicitly, you return when execution reaches the end of a
>> > function. In fact the same is true of PHP and JavaScript, but in those
>> > languages you can return early just by saying return.
>>
>> > IMO, this is a major limitation of Pascal. I use returns wherever I feel
>> > like it - if I detect there's nothing more for the function to do, I
>> > return. Purists object to this; they say you should enter a function at one
>> > place and leave at one place. Well, that's a point of view. But more often
>> > that not it just leads to convoluted code in order to achieve that. The one
>> > time I *had* to use Pascal as that was the only option, I simply put a 999:
>> > label at the end of the function and did goto 999 wherever I wanted to do a
>> > return. Simples!
>>
>> goto was the thing that got on my nerves. Even to this day I hate that word
>> with a passion.
>>
>>
>
>
> I think most people do, all but BASIC purists!
>

Not really, goto can safe you a mess. In some situations it's much
easier and cleaner to use something like goto cleanup; at each error
case, instead of duplicating the cleanup code all over again (Closing
sockets, or in languages like C, freeing memory).

- Matijn

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux