"print" method API inconsistency #1012

Open
Util opened this Issue Oct 7, 2013 · 0 comments

Projects

None yet

1 participant

@Util
Member
Util commented Oct 7, 2013

Reported by: zefram@fysh.org

PDD 22 indicates that the "print" method on an I/O handle PMC is meant to return one value, a status object. In fact, while the method on FileHandle does return one value, the corresponding method on StringHandle returns two values:

$ cat t50.pir 
.sub main :main
       $P0 = getstdout
       $S0 = typeof $P0
       say $S0
       ($P1 :slurpy) = $P0."print"("(foo)\n")
       $I0 = $P1
       say $I0
       $P2 = new "StringHandle"
       $S1 = typeof $P2
       say $S1
       $P2."open"("<fake>", "rw")
       ($P3 :slurpy) = $P2."print"("(foo)\n")
       $I1 = $P3
       say $I1
.end
$ ./parrot t50.pir 
FileHandle
(foo)
1
StringHandle
2

There also doesn't seem to be any consistency in what the values returned are. On FileHandle, the returned value is an integer, the number of characters printed. On StringHandle, the first return value is the StringHandle invocant, and the second return value is the string being printed. These are both inconsistent with each other, and inconsistent with PDD 22's promise of a status object.

-zefram

Summary of my parrot 5.7.0 configuration:
 configdate='Sat Oct  5 12:42:43 2013 GMT'
 Platform:
   osname=linux, archname=x86_64-linux-gnu-thread-multi
   perl=/usr/bin/perl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment