1 # Copyright (C) 2007-2009, Parrot Foundation.
6 The C<defined> opcode tells you if the contents of a PMC is defined or not.
7 Using C<defined> on a C<int>, C<num>, or C<string> register may generate
8 an error if the register has been used before and freed or is newly created.
10 C<defined> is a great way to test a PMC to ensure it's been set to a proper
11 value before attempting to use it. Attempting to use a PMC that has not
12 been defined may throw an exception or cause a bigger problem.
20 if $I0 goto defined_P1
21 say "$P1 is undefined"
28 Most PMC's, but not all, should return true for C<defined>. It all
29 depends on how the PMC implements its vtable method for C<defined>.
30 For example the C<Undef> PMC always returns false (0) for C<defined>.
37 if $I0 goto defined_P3
38 say "$P3 is undefined"
51 # vim: expandtab shiftwidth=4 ft=pir: