# New Ticket Created by  Zach Morgan 
# Please include the string:  [perl #50220]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=50220 >


severity: medium
category: languages

hello, all.  Attached (hopefully) is a patch to implement get_string for
perl6's junctions. I looked in synopsis 9 and saw nothing about any
get_string, so I decided on the simplest, most straightforward approach.

Admittedly, I don't know enough about junctions to say for certain whether
this will actually be used. Should say 4&5 call say for both 4 and 5 or just
once for the junction? At the moment however, it looks for get_string for
the junction type. I suspect that it will at least aid in debugging, at the
very least.

Zach Morgan
Index: languages/perl6/src/classes/Junction.pir
===================================================================
--- languages/perl6/src/classes/Junction.pir	(revision 25207)
+++ languages/perl6/src/classes/Junction.pir	(working copy)
@@ -27,6 +27,47 @@
 .end
 
 
+=item get_string()    (vtable method)
+
+Return the elements of the junction joined by commas, identified by junction type.
+
+=cut
+
+.sub 'get_string' :vtable :method
+
+    # Now go by juction type.
+    .local int type
+    .local pmc values
+    .local string res
+    .local string tmp
+    type = self.'!type'()
+    if type == JUNCTION_TYPE_ALL goto all
+    if type == JUNCTION_TYPE_ANY goto any
+    if type == JUNCTION_TYPE_ONE goto one
+    if type == JUNCTION_TYPE_NONE goto none
+
+all:
+    res = 'all'
+    goto okay
+any:
+    res = 'any'
+    goto okay
+one:
+    res = 'one'
+    goto okay
+none:
+    res = 'none'
+    goto okay
+okay:
+    values = self.'values'()
+    tmp = join ',', values
+    concat res, '('
+    concat res, tmp
+    concat res, ')'
+    .return (res)
+.end
+
+
 =item values()
 
 Get the values in the junction.

Reply via email to