Re: constant in object

2014-02-10 Thread Uri Guttman
On 02/11/2014 02:21 AM, shawn wilson wrote: why not add more code that doesn't do anything useful? code is not telling the computer what to do. code is for telling the reader of the code what your logical decisions are. On Tue, Feb 11, 2014 at 1:13 AM, John SJ Anderson wrote: TL;DR - if y

Re: constant in object

2014-02-10 Thread shawn wilson
> why not add more code that doesn't do anything useful? code is not telling > the computer what to do. code is for telling the reader of the code what your > logical decisions are. On Tue, Feb 11, 2014 at 1:13 AM, John SJ Anderson wrote: > > TL;DR - if you can't offer a positive reason why yo

Re: constant in object

2014-02-10 Thread Uri Guttman
On 02/11/2014 01:07 AM, shawn wilson wrote: I kinda got that's what it was for, I just never thought it was a bad idea I also don't have any real use for the functionality in what I'm working on. I guess the thought was that, why take something away that someone might want to use that doesn'

Re: constant in object

2014-02-10 Thread John SJ Anderson
On Mon, Feb 10, 2014 at 10:07 PM, shawn wilson wrote: > which I still don't see why this is bad? In "classic" object-oriented programming, object constructors -- which is what new() is in your class -- are always class methods. Calling 'new()' as an object method doesn't make any sense. Further

Re: constant in object

2014-02-10 Thread shawn wilson
On Tue, Feb 11, 2014 at 12:42 AM, Uri Guttman wrote: > On 02/11/2014 12:13 AM, shawn wilson wrote: >> >> On Mon, Feb 10, 2014 at 11:50 PM, Uri Guttman wrote: > > sub new { my ($proto) = @_; my $class = ref($proto) || $proto; >>> >>> >>> >>> don't do that style of getti

Re: constant in object

2014-02-10 Thread Uri Guttman
On 02/11/2014 12:13 AM, shawn wilson wrote: On Mon, Feb 10, 2014 at 11:50 PM, Uri Guttman wrote: sub new { my ($proto) = @_; my $class = ref($proto) || $proto; don't do that style of getting the class. it is meant to handle class or object method calls and is considered poor design

Re: constant in object

2014-02-10 Thread shawn wilson
On Mon, Feb 10, 2014 at 11:50 PM, Uri Guttman wrote: > On 02/10/2014 11:35 PM, shawn wilson wrote: >> >> my $foo = [qw/one two three/]; > > > that assignment happens later. $foo isn't set when new is called yet. > Ah, of course - thanks. > >> >> sub new >> { >>my ($proto) = @_; >>my $cl

Re: constant in object

2014-02-10 Thread Uri Guttman
On 02/10/2014 11:35 PM, shawn wilson wrote: Why doesn't $foo show up in the object? Ways around it are obvious - just have a helper method: sub foo {return [qw/one two three/]} but I don't understand why I don't have access to the variable within the same package? use strict; use warnings; use

constant in object

2014-02-10 Thread shawn wilson
Why doesn't $foo show up in the object? Ways around it are obvious - just have a helper method: sub foo {return [qw/one two three/]} but I don't understand why I don't have access to the variable within the same package? use strict; use warnings; use Data::Dumper; my $t = T->new(); print Dumper