Skip Menu |

This queue is for tickets about the Graph CPAN distribution.

Report information
The Basics
Id: 9505
Status: resolved
Priority: 0/
Queue: Graph

People
Owner: Nobody in particular
Requestors: mre2007 [...] cs.columbia.edu
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.50
Fixed in: 0.20105



Subject: Problems with Inheritance of the base Graph class
I'm am getting the following problems with the 0.5 version of Graph. bash-2.05$ ./testing.pl Not an ARRAY reference at /<snip>/lib/perl5/site_perl/5.8.0/Graph.pm line 481. bash-2.05$ cat testing.pl #!/usr/bin/perl use strict; use warnings; use Graph::Test; my $G = Graph::Test->new(); if($G->has_edge("foo", "bar")) { print "hi"; } bash-2.05$ cat Graph/Test.pm package Graph::Test; use base ("Graph"); use PDL; sub new { my $invocant = shift; my $class = ref($invocant) || $invocant; my $self = { L => pdl [], @_, }; return bless $self, $class; } 1; This works fine in Graph-0.20105... This breaks a lot of my classes based on Graph... This is perl, v5.8.0 built for i386-linux-thread-multi Linux <snip> 2.4.20-31.9.progeny.5smp #1 SMP Tue Aug 10 01:31:24 EDT 2004 i686 i686 i386 GNU/Linux
I do not think this is a problem with inheritance as such (there are some basic inheritance tests in the test suite), but rather with making assumptions about the internal implementation of Graph. By doing bless { L => ..., @_ }, ... one is making the assumptions that a Graph is a blessed hash reference and that the hash key 'L' is free to use. Neither assumptions is true with Graph 0.50: Graphs are blessed array references, and none of the array slots are available for users. But that is all internal detail. I'm afraid you will have to change your code. A future-proof way would be to use graph attributes: in your derived new() do a Graph->new() and then call set_graph_attribute().
As I commented earlier, I can't consider this to be a bug.
From: mre2007 [...] cs.columbia.edu
[JHI - Wed Jan 12 12:02:03 2005]: Show quoted text
> As I commented earlier, I can't consider this to be a bug.
I agree it's not a bug, but it threw me off when the new 0.50 version wasn't backwards compatiable. I'll try to use your example code and modify my code. If you have a good piece of example code, of how things are _supposed_ to be done to remain compatiable with future versions, I would appreciate it =) Otherwise, I think I can figure it out. Thanks, -Marc
Date: Sat, 15 Jan 2005 18:03:34 +0200
From: Jarkko Hietaniemi <jhi [...] iki.fi>
To: bug-Graph [...] rt.cpan.org
Subject: Re: [cpan #9505] Problems with Inheritance of the base Graph class
RT-Send-Cc:
Guest via RT wrote: Show quoted text
> This message about Graph was sent to you by guest <> via rt.cpan.org > > Full context and any attached attachments can be found at: > <URL: https://rt.cpan.org/Ticket/Display.html?id=9505 > > > [JHI - Wed Jan 12 12:02:03 2005]: > >
>>As I commented earlier, I can't consider this to be a bug.
> > > I agree it's not a bug, but it threw me off when the new 0.50 version > wasn't backwards compatiable.
Understandable but then again, I would not expect that from any 0.anything releases of any software. Show quoted text
> I'll try to use your example code and modify my code. If you have a good > piece of example code, of how things are _supposed_ to be done to remain > compatiable with future versions, I would appreciate it =) Otherwise, I > think I can figure it out. > > Thanks, > -Marc
No, I don't have any ready example code. Just use graph attributes to attach your own data. -- Jarkko Hietaniemi <jhi@iki.fi> http://www.iki.fi/jhi/ "There is this special biologist word we use for 'stable'. It is 'dead'." -- Jack Cohen