in reply to Re^5: Assignable Subroutines
in thread Assignable Subroutines

$obj->thing(15000, 20000) =~ s[something][else]g;

might be easier to read as:

$spreadsheet->cell('C3', 'D4') =~ s[something][else]g;

There has to be a clean, and I mean absolutely clean, way of doing this - which P6 is either giving to us, or will get us very close to. What we have in P5 is not even close:

# current lvalue sub: (my $val = $spreadsheet->cell('C3', 'D4')) =~ s[something][else]g; $spreadsheet->cell('C3', 'D4') = $val; $spreadsheet->recalc() if $spreadsheet->autorecalc(); # without lvalue sub: (my $val = $spreadsheet->cell('C3', 'D4')) =~ s[something][else]g; $spreadsheet->cell('C3', 'D4', $val);

A world of difference syntactically in the problem domains where this makes sense. With the current lvalue sub, you can't hook in after the assignment to do things (such as validation, or, as above, recalculating the sheet). Without the lvalue sub, we can do this, but syntactically it's a bit more awkward.

Replies are listed 'Best First'.
Re^7: Assignable Subroutines
by exussum0 (Vicar) on Jan 25, 2005 at 19:01 UTC
    I dislike both syntaxes for assignment of values. I would suspect.. $spreadSheet->getCell('C1','C5')->setValue('123');

    Biggest reason to have the Cell as an object is that a cell isn't a string. It's an object that contains a value. In fact, in spreadsheet context, it has other attributes, such as formatting, margins and other sillinesses...

    ----
    Give me strength for today.. I will not talk it away..
    Just for a moment.. It will burn through the clouds.. and shine down on me.