Skip Menu |

This queue is for tickets about the LinkedList-Single CPAN distribution.

Report information
The Basics
Id: 133093
Status: open
Priority: 0/
Queue: LinkedList-Single

People
Owner: Nobody in particular
Requestors: jo [...] sommrey.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: bool overload not working
Date: Sat, 01 Aug 2020 14:16:51 +0000
To: bug-LinkedList-Single [...] rt.cpan.org
From: Jörg Sommrey <jo [...] sommrey.de>
Hi, the bool overload does not stop at the end of the list. There is a commented additional condition in the source that would fix this issue, but probably would cause some other trouble. #!/usr/bin/perl use strict; use warnings; use LinkedList::Single; my $lh = LinkedList::Single->new(1, 2, 3); $lh->head; my $emergency_stop = 5; while ($lh) { print 'node: ', $lh->node_data, "\n"; do {print "emergency exit taken\n"; last} unless --$emergency_stop; } continue { $lh->next; } __DATA__ node: 1 node: 2 node: 3 node: node: emergency exit taken
Subject: Re: [rt.cpan.org #133093] bool overload not working - patch
Date: Sun, 02 Aug 2020 11:00:15 +0000
To: Bugs in LinkedList-Single via RT <bug-LinkedList-Single [...] rt.cpan.org>
From: Jörg Sommrey <jo [...] sommrey.de>
Here is a patch for this issue: --- /usr/local/share/perl/5.20.2/LinkedList/Single.pm 2014-09-08 19:54:41.000000000 +0200 +++ LinkedList/Single.pm 2020-08-02 12:06:03.151799072 +0200 @@ -26,7 +26,9 @@ my $listh = shift; - $$listh # && @{ $$listh } + # the second test seems to be required! + #$$listh # && @{ $$listh } + $$listh && @{ $$listh } }, # return a node at the given offset.
CC: lembark [...] wrkhors.com
Subject: Re: [rt.cpan.org #133093] bool overload not working
Date: Mon, 10 Aug 2020 22:11:09 -0400
To: bug-LinkedList-Single [...] rt.cpan.org
From: Steven Lembark <lembark [...] wrkhors.com>
Show quoted text
> the bool overload does not stop at the end of the list. There is a > commented additional > condition in the source that would fix this issue, but probably would > cause some other trouble.
One of the things I dropped from the singly linked list is a specific counter for length. Problems start if the list is accessed from multiple threads: there is too much overhead required to bookkeep the list in most cases when length is added. Part of the issue is that nothing prevents you from dropping or inserting a node by directly manipulating the node struct (it is intentionally rather simple to allow for this). If the emergency_stop is something you really need then I'd suggest deriving a class that implements it in the way you need it to work. The existing model depends on checking $node = $list->next (which will be undef when you hit the placeholder node). Q: Does maintaining the trailing (empty) tail node cause a problem in your application? Show quoted text
> #!/usr/bin/perl > > use strict; > use warnings; > use LinkedList::Single; > > my $lh = LinkedList::Single->new(1, 2, 3); > $lh->head; > > my $emergency_stop = 5; > while ($lh) { > print 'node: ', $lh->node_data, "\n"; > do {print "emergency exit taken\n"; last} unless > --$emergency_stop; } continue { > $lh->next; > } > __DATA__ > node: 1 > node: 2 > node: 3 > node: > node: > emergency exit taken >
-- Steven Lembark Workhorse Computing lembark@wrkhors.com +1 888 359 3508
Subject: Re: [rt.cpan.org #133093] bool overload not working
Date: Tue, 11 Aug 2020 11:33:43 +0000
To: "lembark [...] wrkhors.com via RT" <bug-LinkedList-Single [...] rt.cpan.org>
From: Jörg Sommrey <jo [...] sommrey.de>
On Tue 11 Aug 2020 04:11:16 AM CEST, "lembark@wrkhors.com via RT" <bug-LinkedList-Single@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=133093 > > >
>> the bool overload does not stop at the end of the list. There is a >> commented additional >> condition in the source that would fix this issue, but probably would >> cause some other trouble.
> > One of the things I dropped from the singly linked list is a specific > counter for length. Problems start if the list is accessed from multiple > threads: there is too much overhead required to bookkeep the list in > most cases when length is added. Part of the issue is that nothing > prevents you from dropping or inserting a node by directly manipulating > the node struct (it is intentionally rather simple to allow for this). > > If the emergency_stop is something you really need then I'd suggest > deriving a class that implements it in the way you need it to work.
The loop (without the emergency exit) is taken from LinkedList::Single's documentation but it does not work. The emergency exit was added to show that there is an otherwise endless loop. Show quoted text
> > The existing model depends on checking $node = $list->next (which will > be undef when you hit the placeholder node). > > Q: Does maintaining the trailing (empty) tail node cause a problem in > your application?
I'm not sure if I understand this question. I've never used an empty tail node intentionally.
CC: lembark [...] wrkhors.com
Subject: Re: [rt.cpan.org #133093] bool overload not working
Date: Tue, 11 Aug 2020 08:39:27 -0400
To: bug-LinkedList-Single [...] rt.cpan.org
From: Steven Lembark <lembark [...] wrkhors.com>
That's where I blew it: Botched example. I'll update that today. -- Steven Lembark Workhorse Computing lembark@wrkhors.com +1 888 359 3508