Navigation Menu

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

PATCH: Add .get method to Iterator #913

Closed
p6rt opened this issue Apr 19, 2009 · 8 comments
Closed

PATCH: Add .get method to Iterator #913

p6rt opened this issue Apr 19, 2009 · 8 comments

Comments

@p6rt
Copy link

p6rt commented Apr 19, 2009

Migrated from rt.perl.org#64858 (status was 'resolved')

Searchable as RT64858$

@p6rt
Copy link
Author

p6rt commented Apr 19, 2009

From @skids

prefix​:<=> has been summarily executed.

@p6rt
Copy link
Author

p6rt commented Apr 19, 2009

From @skids

0001-Add-.get-to-Iterator.patch
From 49abde08f49bb6b3b3a201bc8599fcb093549102 Mon Sep 17 00:00:00 2001
From: root <root@charon.clarku.edu>
Date: Sun, 19 Apr 2009 15:04:17 -0400
Subject: [PATCH] Add .get to Iterator.
 Also added name=>Iterator to class constructor

---
 src/classes/Iterator.pir |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/classes/Iterator.pir b/src/classes/Iterator.pir
index eed4fae..aca7f38 100644
--- a/src/classes/Iterator.pir
+++ b/src/classes/Iterator.pir
@@ -17,8 +17,29 @@ Iterator - Perl 6 iterator
 .sub 'onload' :anon :init :load
     .local pmc p6meta, iterproto
     p6meta = get_hll_global ['Perl6Object'], '$!P6META'
-    iterproto = p6meta.'new_class'('Perl6Iterator', 'parent'=>'Any')
+    iterproto = p6meta.'new_class'('Perl6Iterator', 'parent'=>'Any', 'name'=>'Iterator')
     p6meta.'register'('Iterator', 'parent'=>iterproto, 'protoobject'=>iterproto)
+
+    $P0 = get_hll_namespace ['Perl6Iterator']
+    '!EXPORT'('get', 'from'=>$P0, 'to_p6_multi'=>1)
+.end
+
+=head2 Methods
+
+=over
+
+=item get
+
+Returns the value at the current position in the Iterator and
+prepares the Iterator to read the next value the next time
+C<get> is invoked on it.
+
+=cut
+
+.namespace ['Perl6Iterator']
+.sub 'get' :method
+     $P0 = shift self
+    .return ($P0)
 .end
 
 =back
-- 
1.6.2.2

@p6rt
Copy link
Author

p6rt commented Apr 19, 2009

From @moritz

On Sun Apr 19 12​:38​:24 2009, bri@​abrij.org wrote​:

prefix​:<=> has been summarily executed.

Thank you very much for your patch.

I'm a bit confused though - why is prefix​:<=> in IO.pir, while .get is
in Iterator.pir - both seem to have the same function. Is there a good
reason for that?

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Apr 19, 2009

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

@p6rt
Copy link
Author

p6rt commented Apr 20, 2009

From @skids

On Sun, 19 Apr 2009, Moritz Lenz via RT wrote​:

I'm a bit confused though - why is prefix​:<=> in IO.pir, while .get is
in Iterator.pir - both seem to have the same function. Is there a good
reason for that?

Iterator will support .get. It's unclear whether IO will as well,
or whether it will stay exclusively with .getc/.readline. They were
both supposed to support prefix​:<=> but prefix​:<=> was not implemented
for Iterator in rakudo.

Even if both support .get, Iterators and IO objects will have different
implementations. This is the implementation for Iterator, which is
currently mostly a boxed Parrot primitive type.

As I did not know what the eventual intent was with IO, I did not try
to implement .get also for the IO class.

@p6rt
Copy link
Author

p6rt commented Apr 22, 2009

From @pmichaud

On Sun, Apr 19, 2009 at 07​:38​:07PM -0400, Brian S. Julin wrote​:

Iterator will support .get. It's unclear whether IO will as well,
or whether it will stay exclusively with .getc/.readline.

It's fairly certain that IO will use .get -- indeed, it
was IO that caused us to change from prefix​:<=> to .get in
the first place.

Even if both support .get, Iterators and IO objects will have different
implementations. This is the implementation for Iterator, which is
currently mostly a boxed Parrot primitive type.

Iterator probably ought to become a role instead of a class.
In that sense we will likely stop using the Parrot primitive
type for our Iterators (or they'll be suitably wrapped in
something that does the Iterator role).

Pm

@p6rt
Copy link
Author

p6rt commented Mar 24, 2010

From @jnthn

Patch will not be relevant now since Iterator has been totally
re-implemented since; closing ticket.

@p6rt
Copy link
Author

p6rt commented Mar 24, 2010

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Mar 24, 2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant