Re: couple questions about refs

2002-12-17 Thread John W. Krahn
Christopher J Bottaro wrote: > > On Tuesday 17 December 2002 04:38 am, Paul Johnson wrote: > > I think Perl actually made me a better C programmer, but it is sometimes > > frustrating going down to the level of C. Keep your hand in with XS > > programming :-) > > what is XS programming? perldoc

Re: couple questions about refs

2002-12-17 Thread christopher j bottaro
On Tuesday 17 December 2002 04:38 am, Paul Johnson wrote: > I think Perl actually made me a better C programmer, but it is sometimes > frustrating going down to the level of C. Keep your hand in with XS > programming :-) what is XS programming? > Yes. And occassionally even if there isn't. Per

Re: couple questions about refs

2002-12-17 Thread Jenda Krynicky
From: Paul Johnson <[EMAIL PROTECTED]> > On Tue, Dec 17, 2002 at 12:39:41AM -0600, christopher j bottaro wrote: > > just that memory will stay allocated as long as there is a way to > > reach it? > > Yes. And occassionally even if there isn't. Perl 5 uses reference > counting, and so you have to

Re: couple questions about refs

2002-12-17 Thread Paul Johnson
On Tue, Dec 17, 2002 at 12:39:41AM -0600, christopher j bottaro wrote: > cool beans, thanks. wow, perl is neat, but i fear it will make me a > bad c programmer...;) I think Perl actually made me a better C programmer, but it is sometimes frustrating going down to the level of C. Keep your hand

Re: couple questions about refs

2002-12-16 Thread christopher j bottaro
cool beans, thanks. wow, perl is neat, but i fear it will make me a bad c programmer...;) so i guess there is no concept of stack and heap space when dealing with perl? just that memory will stay allocated as long as there is a way to reach it? hehe, i can't wait to abuse that fact;) ch

Re: couple questions about refs

2002-12-16 Thread John W. Krahn
Christopher J Bottaro wrote: > > hmm, something is going off in my head that says this is scary. Calm down Christopher. :-) > @array is > local to the function (lexically scoped as you would say in perl??) and you > are returning a reference to it. Yes, that is correct. > well when the functi

Re: couple questions about refs

2002-12-16 Thread christopher j bottaro
On Monday 16 December 2002 08:50 am, Jenda Krynicky wrote: > > i know what i really should do is this: > > sub myfunc(){ > > my @array; > > if ( some_cond ) { > > return undef; > > } > > else { > > #populate @array > > return [ @array ]; > > } > > } > > Well ... I would u

Re: couple questions about refs

2002-12-16 Thread John W. Krahn
Nyimi Jose wrote: > > > From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] > > > > From: christopher j bottaro <[EMAIL PROTECTED]> > > > > > > #populate @array > > > return [ @array ]; > > > } > > > } > > > > Well ... I would use > > > > return \@array; > > > > it's a bit m

RE: couple questions about refs

2002-12-16 Thread NYIMI Jose (BMB)
00) José. > -Original Message- > From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 16, 2002 3:51 PM > To: [EMAIL PROTECTED] > Subject: Re: couple questions about refs > > > From: christopher j bottaro <[EMAIL PROTECTED]

Re: couple questions about refs

2002-12-16 Thread Rob Richardson
Chris, I'll take a stab at this to see if my understanding of Perl is correct. Your first subroutine is acceptable under Perl, but it wouldn't be under C++. The reason is that Perl has automatic reference counting and garbage collection. Perl counts the number of references there are to data el

Re: couple questions about refs

2002-12-16 Thread Jenda Krynicky
From: christopher j bottaro <[EMAIL PROTECTED]> > hello again, > all my c instincts tell me i shouldn't write a function like this: sub > myfunc() { > my $aref = []; > if ( some_cond ) { > return undef; > } > else { > #populate @{$aref} > return $aref; > } > }