Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

ethan (3163)

  reversethis-{ed. ... rap.nov.olissat}

Being a 25-year old chap living in the western-most town of Germany. Stuying communication and information science and being a huge fan of XS-related things.

Journal of ethan (3163)

Saturday October 23, 2004
01:11 AM

An 'unreportable' perl bug revisited

[ #21477 ]

In my last entry I mumbled something about a tricky bug in perl that was allegedly unreportable. Good so because as it turned out, it wasn't a bug at all. I had this kind of setup:

    sub search {
    my ($self, $state) = @_;
    # $state->{last_search} being an array-ref of previous
    # search patterns. You were supposed to cycle through them
    # with TAB
    my $pattern = $self->get_input($state, $state->{last_search});
    # once a list of matchings songs has been returned and the user
    # chose one of them to play
    sub get_input {
    my ($self, $state, $searches) = @_;
    if ($hit_key == KEY_TAB) {
        push @$searches, shift @$searches;
        goto &search;
    return $search_pattern;

The above is naturally just a simplification. There are several event-loops going on at once so I kind of had to chose such an awkward way. Now the thing is that goto &func replaces the running instance of a function with &func. When looking at search() it becomes obvious that this would eventually expand to:

    my $pattern = $self->search($state);

which is wrong as now $pattern would contain the return value of search which would be its last value evaluated ($state->playlist->play always returns 1). Now I changed things so that get_input does a goto &get_input instead.

So far I always thought that goto &func would be one of those less harmful things. But in fact, it's even worse than anything Dijkstra described in his pamphlet.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.