David Storrs <[EMAIL PROTECTED]> writes:

> So, as I sweat here in the salt mines of C++, longing for the
> cleansing joy that Perl(5 or 6, I'd even take 4) is, I find myself
> with the following problem:
>
> Frequently, I find myself writing stuff like this:
>
> void Ficp400::SaveRow(long p_row) 
> {
>       // if p_row is marked as deleted, return
>       if (GetStatus(row) & FLX_ROW_DELETE) { return; }
>
>       ...
> }
>
> As a general rule, I don't like comments.  When I see a comment, I
> want to turn it into a function name.  So, I keep wanting to be able
> to write the above code like so:
>
>
>
> void Ficp400::SaveRow(long p_row) 
> {
>       Return_If_Is_Deleted(p_row);
>
>       ...
> }
>
> Now, in C++ (or P6, FTM), I could make this work via a macro, but
> that's ugly.  In P6, I could make it work by passing the current
> continuation down to Return_If_Is_Deleted and call the continuation if
> the row is in fact deleted, but that will require an extra param.  Is
> there a way to make it work as written?  I'm thinking maybe the
> C<caller> object would have something that would allow me to jump to
> the right point (i.e., caller[2]).

Something in Damian's talk this morning reminded me that:

   void Ficp400::SaveRow(long p_row) {
       when row_is_deleted { }
       ...
   }

Will do a magic return. I do wonder if it'll simply return from
SaveRow, or from the innermost enclosing C<given>

-- 
Piers

Reply via email to