Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X::Seq don't say which Seq the exception occurred on #6033

Open
p6rt opened this issue Jan 25, 2017 · 6 comments
Open

X::Seq don't say which Seq the exception occurred on #6033

p6rt opened this issue Jan 25, 2017 · 6 comments
Labels
LTA Less Than Awesome; typically an error message that could be better

Comments

@p6rt
Copy link

p6rt commented Jan 25, 2017

Migrated from rt.perl.org#130638 (status was 'open')

Searchable as RT130638$

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @samcv

CODE​:
my Seq $thing = (1,3,4).Seq; $thing.iterator; $thing.iterator

STDERR​:
This Seq has already been iterated, and its values consumed
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
  in block <unit> at <unknown file> line 1

I have had lines that have multiple sequences on that, and it is very difficult to know which Seq it was without a nice error.

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @moritz

On Tue, 24 Jan 2017 23​:15​:32 -0800, samantham@​posteo.net wrote​:

CODE​:
my Seq $thing = (1,3,4).Seq; $thing.iterator; $thing.iterator

STDERR​:
This Seq has already been iterated, and its values consumed
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <unknown file> line 1

I have had lines that have multiple sequences on that, and it is very
difficult to know which Seq it was without a nice error.

What would you suggest we do? The point of the Seq iterator is that it doesn't generally store the old values, so pretty much by definition we *can't* give more details about the contents of the Seq, and we generally don't know which variable it's stored in either.

Unless somebody has a good idea on how to improve this, I'd close it as "sadly won't fix".

Cheers,
Mority

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @samcv

On Wednesday, 25 January 2017 01.45.59 PST you wrote​:

On Tue, 24 Jan 2017 23​:15​:32 -0800, samantham@​posteo.net wrote​:

CODE​:
my Seq $thing = (1,3,4).Seq; $thing.iterator; $thing.iterator

STDERR​:
This Seq has already been iterated, and its values consumed
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <unknown file> line 1

I have had lines that have multiple sequences on that, and it is very
difficult to know which Seq it was without a nice error.

What would you suggest we do? The point of the Seq iterator is that it doesn't generally store the old values, so pretty much by definition we *can't* give more details about the contents of the Seq, and we generally don't know which variable it's stored in either.

Unless somebody has a good idea on how to improve this, I'd close it as "sadly won't fix".

Cheers,
Mority

I don't want the values of the Seq, I want the name of the variable.

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @moritz

On 25.01.2017 10​:47, Samantha McVey wrote​:

On Wednesday, 25 January 2017 01.45.59 PST you wrote​:

On Tue, 24 Jan 2017 23​:15​:32 -0800, samantham@​posteo.net wrote​:

CODE​:
my Seq $thing = (1,3,4).Seq; $thing.iterator; $thing.iterator

STDERR​:
This Seq has already been iterated, and its values consumed
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <unknown file> line 1

I have had lines that have multiple sequences on that, and it is very
difficult to know which Seq it was without a nice error.

What would you suggest we do? The point of the Seq iterator is that it doesn't generally store the old values, so pretty much by definition we *can't* give more details about the contents of the Seq, and we generally don't know which variable it's stored in either.

Unless somebody has a good idea on how to improve this, I'd close it as "sadly won't fix".

Cheers,
Mority

I don't want the values of the Seq, I want the name of the variable.

Trying to find the name of a variable (if there is one at all) from the
object is inherently brittle, and has lead to many false positives in
the past (like reporting the name of a parameter from a routine in CORE
somewhere).

--
Moritz Lenz
https://deploybook.com/ -- https://perlgeek.de/ -- https://perl6.org/

@p6rt
Copy link
Author

p6rt commented Jan 25, 2017

From @lizmat

I think this is a basic misunderstanding about what an Iterator is and what a Seq.

The basic thing is the Iterator.

.Seq is nothing but method Seq() { Seq.new(self.iterator) }

In other words, a Seq is just a wrapper around an Iterator.

In general, you shouldn’t be asking a Seq for its Iterator. You could argue that is something that is only done internally to make things work(tm).

Also, unless you’re writing iterators yourself, you should never even need to know about iterators. So I’m wondering what you’re trying to achieve.

If you change the code to​:

  my $thing = (1,3,4); $thing.iterator; $thing.iterator

it would just give you two iterators. Each iterating over the whole list. Not sure if that’s what you wanted to do, but that cannot be determined from the code provided.

Also, I’m not sure how we can improve the error message​: most Seq’s are created inside the core setting. And when the “already consumed” error occurs, it’s going to be hard to find out where that Seq got created.

So I would categorize this bug as a DIHWIDT

On 25 Jan 2017, at 08​:15, Samantha McVey (via RT) <perl6-bugs-followup@​perl.org> wrote​:

# New Ticket Created by Samantha McVey
# Please include the string​: [perl #​130638]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl6/Ticket/Display.html?id=130638 >

CODE​:
my Seq $thing = (1,3,4).Seq; $thing.iterator; $thing.iterator

STDERR​:
This Seq has already been iterated, and its values consumed
(you might solve this by adding .cache on usages of the Seq, or
by assigning the Seq into an array)
in block <unit> at <unknown file> line 1

I have had lines that have multiple sequences on that, and it is very difficult to know which Seq it was without a nice error.

@p6rt p6rt added the LTA Less Than Awesome; typically an error message that could be better label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
LTA Less Than Awesome; typically an error message that could be better
Projects
None yet
Development

No branches or pull requests

1 participant