Re: [Class::MultiList] Need feedback for first distribution

2004-01-21 Thread Ruslan U. Zakirov
David Manura wrote:
Hi Ruslan,

Do you have a link?  or some POD documentation?

-davidm
I realy realy sorry, I've forgot to attach file :(
Was tired a lot.
Ruslan U. Zakirov wrote:

Hello.
I'm planning to do my first CPAN upload.
I realy need some feedback.
Reasons:
1) Module is very simple, but I like it and use it.
2) I didn't find any similar on CPAN.
Questions:
1) I'm not native English speaker, so I want some feedback about 
Name.
2) Code, coding style, and so.
3) Something like: fo..., useless, suxxx is OK, but with 
reasons :)

My ideas:
1) May be it's better to prefix with _ all funcs which have 
AUTOLOAD magic? There is many such methods in module so it's hard to 
inherit this object.

Best regards. Ruslan.

Beforehead thanks.




package Class::MultiList;

use 5.006;
use strict;
use warnings;

our $VERSION = '0.1';

our $AUTOLOAD;


sub new
{
my $proto = shift;
my $class = ref($proto) || $proto;
my $self  = {};
bless ($self, $class);
return $self;
}

sub InitList
{
my $self = shift;
my $args = {
Name = undef,
@_,
};
die 'Where Name?' unless ($args-{'Name'});
$self-{'Lists'}-{ $args-{'Name'} } = {
List = [],
Current = undef,
Counter = 0,
Hash = {},
};
}

sub AUTOLOAD
{
my $self = shift;

my @avail = qw(Count First Current Last Next Prev Push Pop Unshift Shift);
my $re = join('|', @avail);

my ($func, $list) = ($AUTOLOAD =~ /^.*::($re)(.*)$/);

unless ( $func ) {
my ($package, $filename, $line) = caller;
die $AUTOLOAD Unimplemented in $package. ($filename line $line) \n;
}

unless ( $self-Exists( List = $list ) ) {
die List $list not exists;
}

no strict qw(refs);

*{$AUTOLOAD} = sub { return ( $self-$func( List = $list, @_ ) ) };
return ( $self-$func( List = $list, @_ ) );
}

sub Exists
{
my $self = shift;
my $args = {
List = undef,
@_,
};
return exists($self-{'Lists'}-{ $args-{'List'} });
}

sub Names
{
my $self = shift;
return keys %{$self-{'Lists'}};
}

sub First
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

$list-{'Current'} = 0;
return $self-Current( List = $args-{'List'} );
}

sub Current
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

return $list-{'List'}-{ $list-{'Current'} };
}

sub Last
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

$list-{'Current'} = $self-Count( List = $args-{'List'} );
return $self-Current( List = $args-{'List'} );
}

sub Next
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

$list-{'Counter'}++;

return $self-Current( List = $args-{'List'} )
if( $list-{'Counter'}  $self-Count( List = $args-{'List'} ) );

$list-{'Counter'} = undef;
return undef;
}

sub Prev
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

$list-{'Counter'}--;

return $self-Current( List = $args-{'List'} )
if( $list-{'Counter'} = 0 );

$list-{'Counter'} = undef;
return undef;
}

sub Count
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

return $list-{'Counter'};
}

sub Push
{
my $self = shift;
my $args = {
List = undef,
Element = undef,
Mark = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

if ( $args-{'Mark'} ) {
die 'Mark already exists' if (exists $list-{'Hash'}-{ 
$args-{'Mark'} });
$list-{'Hash'}-{ $args-{'Mark'} } = $list-{'Counter'};
}

$list-{'Counter'}++;
push( @{$list-{'List'}}, $args-{'Element'} );

return;
}

sub Pop
{
my $self = shift;
my $args = {
List = undef,
@_,
};
my $list = $self-__GetList( $args-{'List'} );

$list-{'Counter'}--;

$list-{'Current'} = undef if ( $list-{'Current'} == $list-{'Counter'} );

# check for mark, 

Re: [Class::MultiList] Need feedback for first distribution

2004-01-21 Thread Martyn J. Pearce
Hello Ruslan,

On Wed, Jan 21, 2004 at 01:59:35PM +0300, Ruslan U. Zakirov wrote:
 I realy realy sorry, I've forgot to attach file :(
 Was tired a lot.

A quick glance over prompts my first question: what does this module provide
that other Class generating modules, e.g., Class::MethodMaker,
Class::MakeMethods, Class::Struct, do not?

Mx.


Re: [Class::MultiList] Need feedback for first distribution

2004-01-21 Thread A. Pagaltzis
* david nicol [EMAIL PROTECTED] [2004-01-21 13:09]:
 I think its that as soon as you have AUTOLOAD defined, you
 can't inherit past that point, at least by the ISA mechanism:
 the AUTOLOAD function needs to know how to punt.

You think wrong.

$ perl -l
package Foo;
sub bar { print oy vey };

package Baz;
our @ISA = qw(Foo);
sub AUTOLOAD {};
  
package main;
Baz-bar;
  
^D
oy vey

Cf. perldoc perlobj:

If neither the current class, its named base classes, nor the
UNIVERSAL class contains the requested method, these three
places are searched all over again, this time looking for a
method named AUTOLOAD().

-- 
Regards,
Aristotle
 
If you can't laugh at yourself, you don't take life seriously enough.


Re: [Class::MultiList] Need feedback for first distribution

2004-01-21 Thread Ruslan U. Zakirov
Martyn J. Pearce wrote:
Hello Ruslan,

On Wed, Jan 21, 2004 at 01:59:35PM +0300, Ruslan U. Zakirov wrote:

I realy realy sorry, I've forgot to attach file :(
Was tired a lot.


A quick glance over prompts my first question: what does this module provide
that other Class generating modules, e.g., Class::MethodMaker,
Class::MakeMethods, Class::Struct, do not?
	Hello, Martyn and other.

Class::Struct - it's implementation of C like structs. Looking in source 
said that it does not like ISA at all so It's not OO style at all.
This module has no similarity in reasons and goals of mine.

I didn't find any similarity with Class::MakeMethods.
I'm going in another direction.
This module(distro) do much on get/set methods, but not iteration.
I want next features:
1) Ordered container of any elements in its cells.
2) Support for many such containers in one object.
For example:
One Object have next lists:
Attribute
Child
Sibling
3) It's something like 'bidirect lists' in C which have next and prev 
refs, but I want abstract this class from data in cells.
Very good schem:
my $attr = $Obj-Attrs-First;
while ($attr-Next) {
...
}
but force me to change Attr object, so I've decided to use next style:
$Obj-InitList(Name = 'Attr');
$Obj-PushAttr($attr); #or
$Obj-Push(List = 'Attr', Element = $attr);

while (my $attr = $Obj-NextAttr) {
...
}
4) Main goal is walking through list(Next, Prev, First, Last)

5) I don't want to give public interface to internal array what other 
modules do.

6) I consider using of this module in OO enviorment so support for join 
method is something not normal.

I hope I've spot more light with this letter.

		Best regards. Ruslan.
Mx.




Re: [Class::MultiList] Need feedback for first distribution

2004-01-20 Thread david nicol
On Tue, 2004-01-20 at 01:55, khemir nadim wrote:
 I don't understand what the autoloading mechanism has to do with
 inheritance! (Something for me to learn I guess)


I think its that as soon as you have AUTOLOAD defined, you can't
inherit past that point, at least by the ISA mechanism: the AUTOLOAD
function needs to know how to punt.


-- 
david nicol
In order to understand what another person is saying, you must assume that it
is true and try to imagine what it could be true of. (George Miller; 1980.)



Re: [Class::MultiList] Need feedback for first distribution

2004-01-19 Thread David Manura
Hi Ruslan,

Do you have a link?  or some POD documentation?

-davidm

Ruslan U. Zakirov wrote:
Hello.
I'm planning to do my first CPAN upload.
I realy need some feedback.
Reasons:
1) Module is very simple, but I like it and use it.
2) I didn't find any similar on CPAN.
Questions:
1) I'm not native English speaker, so I want some feedback about Name.
2) Code, coding style, and so.
3) Something like: fo..., useless, suxxx is OK, but with reasons :)
My ideas:
1) May be it's better to prefix with _ all funcs which have AUTOLOAD 
magic? There is many such methods in module so it's hard to inherit this 
object.

Best regards. Ruslan.

Beforehead thanks.