Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: How to best pass on the context / wantarray?

by Roy Johnson (Monsignor)
on Mar 27, 2006 at 16:44 UTC ( #539480=note: print w/replies, xml ) Need Help??

in reply to How to best pass on the context / wantarray?

Rather than relying on (possibly subtle) context or having two versions of each method, you might want to have the copy method and the mutator method and call them both when you want a modified copy. That seems the most clear (and flexible) to me. The overhead is not particularly onerous.
$cursor->move_right(3); # move cursor three chars to the right $cursor->move_down(); # move cursor one line downwards # and my $left_pos = $cursor->copy->move_left(1); # position one char to the left of the cursor my $start = $cursor->copy->start_of_document();

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: How to best pass on the context / wantarray?
by saberworks (Curate) on Mar 27, 2006 at 18:41 UTC
    Thank you. I was wondering after reading the original post why he was using the context (list or scalar) to determine whether to operate on a copy or the original. What does "a copy or the original" have to do with "list or scalar context" in general? Nothing! If you want to operate on a copy, grab a copy and operate on it.

    Although, I might be misunderstanding what is going on.
      The difference was between void or non-void context, not between list or scalar.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://539480]
[corenth]: each reference was to a fairly small scaler.
[corenth]: I mean, array of scalers. usually triples.
[Cosmic37]: there is a FANN discussion group but seems to have gone quiet... http://leenissen. dk/fann/forum/ viewforum.php?f=18 &sid=1afc1fb3fa1a3 7f52b03e40d05cdaaa 3
[corenth]: Where are all the FANN fans?
[Cosmic37]: ok it went quiet because it moved - its actually quite active... https://sourceforg discussion/
[Cosmic37]: Therefore they are on sourceforge

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2018-02-20 18:33 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (274 votes). Check out past polls.