Re: auto-initializing values

2000-09-11 Thread Dave Storrs
On Mon, 11 Sep 2000, John Porter wrote: > Dave Storrs wrote: > > > > init_vars \{name => 'NONE'}; > > my @employees : size 50; # 50 entries, each a ref to 1 elem. hash > > @employees = get_from_db('*'); > > for (@employees) { > > if ( $_{name} eq 'NONE' ) { > >

Re: auto-initializing values

2000-09-11 Thread John Porter
Dave Storrs wrote: > > if a "initial size" attribute were added to arrays, then this > could be very useful...say that you have 50 employees, each of whose data > is stored in a hash. Here's an easy way to get a list of references to > all the hashes, with error handling built in: > > ini

RE: auto-initializing values

2000-09-11 Thread Dave Storrs
On Mon, 11 Sep 2000, Myers, Dirk wrote: > >Suppose you could specify the value with which all variables > >in the enclosing scope should be initialized; for example: > > I haven't seen this either, but I suggest that it should be a set of > pragmas: > use init_scalar 0 ; > use init_array () ;

Re: auto-initializing values

2000-09-11 Thread Peter Scott
At 11:55 AM 9/11/00 -0600, Tom Christiansen wrote: >I like this idea Can you explain why? I don't like it, too much action-at-a-distance for me. Does it propagate to enclosed scopes? If I do it at the outer level does it go through the whole file? I would assume so. It's not something I'v

Re: auto-initializing values

2000-09-11 Thread John Porter
Dave Storrs wrote: > > { > # handle pensioners here my ($num_pensioners, $base_pension, $years_service) = (0,0,0); > } > > { my $init_vars = 'ERROR::NAME_NOT_FOUND'; my ($name_1, $spouse_name_1) = ($init_vars)x2; > } > > { m

Re: auto-initializing values

2000-09-11 Thread Tom Christiansen
I like this idea, although not necessarily for the "spurious warnings" reason. --tom

auto-initializing values

2000-09-11 Thread Dave Storrs
This is something fairly basic, but I haven't seen it in discussion or in the RFCs. If I've missed it, my apologies. In Perl 5, when a variable is created, it is given the "undefined" value. This can lead to lots of spurious "Use of uninit'd variable" warnings. Suppose you could specify the val