Re: RFC: Package == class == object type
From: Paul Johnson (paul_at_pjcj.net)
Date: 01/13/04
- Next message: Dr. Irina Campbell: "no digest"
- Previous message: Wiggins D Anconia: "Re: Oreilly's "Learning Perl 3rd Edition""
- In reply to: James Edward Gray II: "Re: RFC: Package == class == object type"
- Next in thread: Gary Stainburn: "Re: RFC: Package == class == object type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 13 Jan 2004 16:26:35 +0100 (CET) To: "James Edward Gray II" <james@grayproductions.net>
>> 2) What I do with the data will obviously depend on the program using
>> my
>> object, but would probably be things like update the screen (Term, TK,
>> Win32), or to send instructions to a control system (e.g. throw points
>> on
>> model railway).
>>
>> What is the best method to pass control back to the program from
>> within a
>> method?
>
> I don't think I understand this question. The obvious answer to me is
> return (exit the method). Control will pass back to the caller at this
> point, as it always does. If I misunderstood, please try explaining it
> again.
I expect you are looking for callbacks here. The caller passes in a sub
(reference) which you call from within the method.
$obj->meth(sub { my ($oomph, $time) = @_; print "Oomph is $oomph at $time" })
and in the module
sub meth
{
my $self = shift;
my ($callback) = @_;
my ($oomph, $time) = ...
$callback->($oomph, $time);
}
-- Paul Johnson - paul@pjcj.net http://www.pjcj.net
- Next message: Dr. Irina Campbell: "no digest"
- Previous message: Wiggins D Anconia: "Re: Oreilly's "Learning Perl 3rd Edition""
- In reply to: James Edward Gray II: "Re: RFC: Package == class == object type"
- Next in thread: Gary Stainburn: "Re: RFC: Package == class == object type"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|