Skip to content

Commit

Permalink
Add concept of stubbing a class should you need to
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jun 4, 2018
1 parent f665d61 commit cbb1ccd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions doc/Language/5to6-nutshell.pod6
Expand Up @@ -1155,9 +1155,22 @@ C<is> keyword, in the class declaration.
package Cat;
use base qw(Animal);
=for code :preamble<class Animal {};>
=for code :preamble<class Animal {}>
# Perl 6
class Cat is Animal {};
class Cat is Animal {}
Note that the C<Animal> class must be B<known> at compilation time. If for
some you need to specify / load your modules in a particular order, you can
create a stub that will be acceptable until the end of compilation: if the
stub has not been defined then, compilation will fail.
=for code :preamble<class Animal {}>
# Perl 6
class Animal { ... } # the ... indicates a stub
class Cat is Animal {}
class Animal {
# the real thing
}
=head3 C<bigint> C<bignum> C<bigrat>
Expand Down

1 comment on commit cbb1ccd

@coke
Copy link
Collaborator

@coke coke commented on cbb1ccd Jun 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails the compilation test.

With the preamble, we get: Redeclaration of symbol 'Animal'

Without it, we get:

# '<anon|45>::Cat' cannot inherit from '<anon|45>::Animal' because '<anon|45>::Animal' isn't composed yet (maybe it is stubbed)

You can run this file itself with:

xt/examples-compilation.t doc/Language/5to6-nutshell.pod6

Please sign in to comment.