Skip to content

Commit 55dcee5

Browse files
leonerdbook
authored andcommitted
Various updates to PPC0022 to sync it to current cpan 'meta' module
1 parent f22f090 commit 55dcee5

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

ppcs/ppc0022-metaprogramming.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,27 +33,17 @@ The get-like functions come in pairs, consisting of a function named `get_...` a
3333

3434
It is currently still an undecided question on what ought to be the correct behaviour for `add`-like functions when asked to create something that already exists, or the `remove`-like functions when asked to remove something that doesn't exist. It may be solved by something similar to above, where there are two differently-named functions that differ in that case. As yet there aren't any particularly compelling solutions.
3535

36-
### Functions to operate on Packages
36+
### Methods to operate on Packages
3737

38-
These are functions to create, manipulate, and inspect packages themselves.
38+
These are methods to create, manipulate, and inspect packages themselves. Packages are represented by instances in the class `meta::package`.
3939

40-
#### `get_package`
40+
#### `get`
4141

4242
```perl
43-
$metapackage = meta::get_package($name);
43+
$metapackage = meta::package->get($name);
4444
```
4545

46-
Returns a meta-package object instance to represent the named package, if such a package exists. If not an exception is thrown.
47-
48-
[[TODO: Decide whether "all packages exist", and thus this can never fail]]
49-
50-
#### `add_package`
51-
52-
```perl
53-
$metapackage = meta::add_package($name);
54-
```
55-
56-
Creates a new package of the given name, and returns a meta-package object instance to represent it.
46+
Returns a meta-package object instance to represent the named package. As conceptually all packages exist, it will be implicitly created if necessary.
5747

5848
#### `list_packages`
5949

@@ -181,14 +171,22 @@ $bool = $metasymbol->is_hash;
181171
$bool = $metasymbol->is_subroutine;
182172
```
183173

184-
Returns true in each of the four cases where the object represents the given type of symbol, or false in the other three cases.
174+
Returns true in each of the five cases where the object represents the given type of symbol, or false in the other four cases.
185175

186176
These methods should not be considered an exhaustive selection. There may be object types to represent other glob slots such as filehandles, formats, and so on. As more types are defined, more methods would be added to distinguish them.
187177

188178
### Methods on Meta-Glob Objects
189179

190180
These methods are available on any meta-symbol object that represents a glob - i.e. one whose sigil is "\*".
191181

182+
#### `get`
183+
184+
```perl
185+
$metaglob = meta::glob->get($name);
186+
```
187+
188+
Returns a meta-glob object instance to represent the named glob from a fully-qualified name, if it exists. If not an exception is thrown.
189+
192190
#### `can_scalar`, `get_scalar`
193191

194192
```perl
@@ -362,6 +360,6 @@ It may be useful to add support for these kinds of abilities somewhere in core p
362360

363361
## Copyright
364362

365-
Copyright (C) 2022-2023, Paul Evans.
363+
Copyright (C) 2022-2024, Paul Evans.
366364

367365
This document and code and documentation within it may be used, redistributed and/or modified under the same terms as Perl itself.

0 commit comments

Comments
 (0)