Skip to content

Commit 138208c

Browse files
committed
Don't use .WHAT, use ^name
Part of #1355
1 parent 513b730 commit 138208c

28 files changed

+93
-85
lines changed

doc/Language/containers.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ you can assign a non-array value to an array variable.
191191
To place a non-C<Array> into an array variable, binding works:
192192
193193
my @a := (1, 2, 3);
194-
say @a.WHAT; # OUTPUT: «(List)␤»
194+
say @a.^name; # OUTPUT: «List␤»
195195
196196
=head1 Binding to array elements
197197

doc/Language/exceptions.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ To handle all exceptions, use a C<default> statement.
6262
6363
CATCH {
6464
default {
65-
say .WHAT.perl, do given .backtrace[0] { .file, .line, .subname }
65+
say .^name, do given .backtrace[0] { .file, .line, .subname }
6666
}
6767
}
6868

doc/Language/faq.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,11 @@ can also contain arrays directly:
313313
314314
my @a = 1, 2, 3;
315315
say @a; # OUTPUT: «[1 2 3]␤»
316-
say @a.WHAT; # OUTPUT: «(Array)␤»
316+
say @a.^name; # OUTPUT: «Array␤»
317317
318318
my $scalar = @a;
319319
say $scalar; # OUTPUT: «[1 2 3]␤»
320-
say $scalar.WHAT; # OUTPUT: «(Array)␤»
320+
say $scalar.^name; # OUTPUT: «Array␤»
321321
322322
The big difference is that arrays inside a scalar act as one value in list
323323
context, whereas arrays will be happily iterated over.

doc/Language/functions.pod6

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,8 @@ with. Parameter defaults and type coercions will work but are not passed on.
300300
301301
=for code :skip-test
302302
proto mistake-proto(Str() $str, Int $number = 42) {*}
303-
multi mistake-proto($str, $number) { say $str.WHAT }
304-
mistake-proto(7, 42); # OUTPUT: «(Int)␤» -- not passed on
303+
multi mistake-proto($str, $number) { say $str.^name }
304+
mistake-proto(7, 42); # OUTPUT: «Int␤» -- not passed on
305305
mistake-proto('test'); # fails -- not passed on
306306
307307
=comment only
@@ -839,8 +839,8 @@ class Bar {
839839
}
840840
841841
sub print-bar(Bar() $bar) {
842-
say $bar.WHAT; # OUTPUT: «(Bar)␤»
843-
say $bar.msg; # OUTPUT: «I'm a foo! But I am now Bar.␤»
842+
say $bar.^name; # OUTPUT: «Bar␤»
843+
say $bar.msg; # OUTPUT: «I'm a foo! But I am now Bar.␤»
844844
}
845845
846846
print-bar Foo.new;

doc/Language/glossary.pod6

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ The I<allomorph> types L<IntStr|/type/IntStr>, L<NumStr|/type/NumStr>,
8585
L<RatStr|/type/RatStr> and L<ComplexStr|/type/ComplexStr> may be created
8686
as a result of parsing a quoted string:
8787
88-
say <42>.WHAT; # OUTPUT: «(IntStr)␤»
89-
say <42.1e0>.WHAT; # OUTPUT: «(NumStr)␤»
90-
say <42.1>.WHAT; # OUTPUT: «(RatStr)␤»
88+
say <42>.^name; # OUTPUT: «IntStr␤»
89+
say <42.1e0>.^name; # OUTPUT: «NumStr␤»
90+
say <42.1>.^name; # OUTPUT: «RatStr␤»
9191
9292
Note: angle brackets can also be used to create literals for which you'd
9393
normally need to use some operator (e.g. C</> for L<Rat> or C<+> for
@@ -103,10 +103,10 @@ expressions are not allowed, for example, as literals in signatures:
103103
If you I<do> want an allomorph and not a literal L<Numeric>,
104104
then include whitespace around angle brackets:
105105
106-
say <42/1>.WHAT; # OUTPUT: «(Rat)␤»
107-
say <42+0i>.WHAT; # OUTPUT: «(Complex)␤»
108-
say < 42+0i >.WHAT;# OUTPUT: «(ComplexStr)␤»
109-
say < 42/1 >.WHAT; # OUTPUT: «(RatStr)␤»
106+
say <42/1>.^name; # OUTPUT: «Rat␤»
107+
say <42+0i>.^name; # OUTPUT: «Complex␤»
108+
say < 42+0i >.^name; # OUTPUT: «ComplexStr␤»
109+
say < 42/1 >.^name; # OUTPUT: «RatStr␤»
110110
111111
=head1 Anonymous
112112
X<|Anonymous>

doc/Language/objects.pod6

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,13 @@ Types themselves are objects and you can get the I<type object> by writing its n
8282
You can ask any object for its type object by calling the C<WHAT> method
8383
(which is actually a macro in method form):
8484
85+
=for code :ok-test<WHAT>
8586
my $int-type-obj = 1.WHAT;
8687
8788
Type objects (other than L<Mu>) can be compared for equality with the
8889
L<C<===>|===> identity operator:
8990
90-
=begin code :allow<B L>
91+
=begin code :allow<B L> :ok-test<WHAT>
9192
9293
sub f(Int $x) {
9394
if $x.WHAT B<L<===>> Int {

doc/Language/subscripts.pod6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ behavior, can be indexed like a hash:
661661
662662
=begin code
663663
my $request = HTTP::Request.new(GET => "perl6.org");
664-
say $request.header.WHAT; # OUTPUT: «(HTTP::Header)␤»
664+
say $request.header.^name; # OUTPUT: «HTTP::Header␤»
665665
666666
$request.header<Accept> = "text/plain";
667667
$request.header{'Accept-' X~ <Charset Encoding Language>} = <utf-8 gzip en>;

doc/Language/typesystem.pod6

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ L<parameters|/type/Signature#Type_Constraints> and return types.
2323
2424
my $a = 1;
2525
$a = Nil;
26-
say $a.WHAT;
27-
# OUTPUT: «(Any)␤»
26+
say $a.^name;
27+
# OUTPUT: «Any␤»
2828
2929
class C {};
3030
say C.^parents(:all);
@@ -40,9 +40,11 @@ To test if an object is a type object, test for definedness and check for
4040
identity between the object and its C<.WHAT> pseudo-method. Note that the
4141
method C<.defined> can be overloaded and may provide false information.
4242
43+
=begin code :ok-test<WHAT>
4344
my $a = Int;
4445
say so $a // $a === $a.WHAT;
4546
# OUTPUT: «True␤»
47+
=end code
4648
4749
=head3 Undefinedness
4850
@@ -272,12 +274,14 @@ compiler, namely C<WHAT>, C<WHO>, C<HOW> and C<VAR>. Declaring methods with
272274
those names will silently fail. A dynamic call will work, what allows to call
273275
methods from foreign objects.
274276
277+
=begin code :ok-test<WHAT>
275278
class A {
276279
method WHAT { "ain't gonna happen" }
277280
};
278281
279282
say A.new.WHAT; # OUTPUT: «(A)␤»
280283
say A.new."WHAT"() # OUTPUT: «ain't gonna happen␤»
284+
=end code
281285
282286
=head4 Methods in package scope
283287
@@ -697,7 +701,7 @@ value types C<Numerical> and C<Str> are supported.
697701
say same(name1, name2); # OUTPUT: «False␤»
698702
my $a = name1;
699703
say $a ~~ Names; # OUTPUT: «True␤»
700-
say $a.WHAT; # OUTPUT: «(Names)␤»
704+
say $a.^name; # OUTPUT: «Names␤»
701705
702706
All keys have to be of the same type.
703707
@@ -721,9 +725,9 @@ Enums can be anonymous. There will be no type created, resulting in a lack of
721725
introspectiveness. The returned object is of type C<Map>.
722726
723727
my $e = enum <one two three>;
724-
say two; # OUTPUT: «two␤»
725-
say one.WHAT; # OUTPUT: «()␤»
726-
say $e.WHAT; # OUTPUT: «(Map)␤»
728+
say two; # OUTPUT: «two␤»
729+
say one.^name; # OUTPUT: «␤»
730+
say $e.^name; # OUTPUT: «Map␤»
727731
728732
There are various methods to get access to keys and values. All of them turn the
729733
values into C<Str>, which may not be desirable. By treating the enum as a

doc/Language/variables.pod6

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ seen in the current expression or declarator:
8080
say $foo.perl; # OUTPUT: «5␤»
8181
8282
my @bar = 7, 9; # list assignment
83-
say @bar.WHAT; # OUTPUT: «(Array)␤»
83+
say @bar.^name; # OUTPUT: «Array␤»
8484
say @bar.perl; # OUTPUT: «[7, 9]␤»
8585
8686
(my $baz) = 11, 13; # list assignment
87-
say $baz.WHAT; # OUTPUT: «(List)␤»
87+
say $baz.^name; # OUTPUT: «List␤»
8888
say $baz.perl; # OUTPUT: «$(11, 13)␤»
8989
9090
Thus, the behavior of an assignment contained within a list assignment depends

doc/Type/Baggy.pod6

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ are the keys and their respective weights the values.
391391
392392
my $breakfast = bag <eggs bacon bacon>;
393393
my $h = $breakfast.hash;
394-
say $h.WHAT; # OUTPUT: «(Hash[Any,Any])␤»
395-
say $h; # OUTPUT: «{bacon => 2, eggs => 1}␤»
394+
say $h.^name; # OUTPUT: «Hash[Any,Any]␤»
395+
say $h; # OUTPUT: «{bacon => 2, eggs => 1}␤»
396396
397397
=head2 method Bool
398398
@@ -428,8 +428,8 @@ Returns a L<SetHash|/type/SetHash> whose elements are the L<keys|#method keys> o
428428
429429
my $breakfast = (eggs => 2, bacon => 3).BagHash;
430430
my $sh = $breakfast.SetHash;
431-
say $sh.WHAT; # OUTPUT: «(SetHash)␤»
432-
say $sh.elems; # OUTPUT: «2␤»
431+
say $sh.^name; # OUTPUT: «SetHash␤»
432+
say $sh.elems; # OUTPUT: «2␤»
433433
434434
=head2 method ACCEPTS
435435

0 commit comments

Comments
 (0)