On Thu, Jun 28, 2012 at 09:41:48PM +0530, Siddhant Saraf wrote:
> (In Rakudo's REPL)
> 
> > say 'a'.WHAT;
> Str()
> > print 'a'.WHAT;
> use of uninitialized variable $v of type Str in string context
> True
> >
> 
> What is happening here? Is this a bug? 
> ( Coz I don't see any $v variable anywhere.)
> What is the "True" indicating?

The part about "$v" is a bug.  It should just be
   "use of uninitialized value of type Str in string context"

Rakudo is correct (with respect to the current spec) to complain 
about printing an undefined value here (all type objects
are undefined, including those returned by .WHAT).  
This is analogous to the Perl 5:

    use warnings;
    print undef;

which results in a "Use of uninitialized value in print" warning.

> What is the "True" indicating?

That's the return value from 'print' in the REPL.  Since the
command given to the REPL didn't produce any output (on $*OUT),
the REPL prints the return value of the print itself (True).

There might be an argument that if anything is displayed on
the standard error that the autoprinting of the result should
be suppressed; but I think I like things this way for now.
Either way, that part isn't a bug.

> May I also take this opportunity to ask someone to explain to 
> me what exactly are the differences between say and print?

print will stringify its arguments and write them to $*OUT.

say will invoke .gist on its arguments and write them (along
with a final newline) to $*OUT.  .gist is intended to provide
human-readable output somewhere between a straight 
Str value ("" in this case) and the the Perlish representation
given by .perl.

To get say to act like "print with a newline", one can do

    say [~] ar


Pm

Reply via email to