Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

pddtypes.pod: more in =head2 const

  • Loading branch information...
commit d1c07ab82fd3acf17803a9f7dbd8e3ab3c5d3903 1 parent 66e9137
@rurban authored
Showing with 14 additions and 9 deletions.
  1. +14 −9 pddtypes.pod
View
23 pddtypes.pod
@@ -55,16 +55,23 @@ calls + optional type checks).
=head2 const
+const is added as type-qualifier to lexical declarations and to packages
+with the feature B<'const'>, which was added with v5.18.
+
Declaration of C<my const> variables and packages allows compile-time
checks, shared strings, lexical scope instead of C<use constant>,
familiar syntax, and efficient optimizations, also for extensions,
as the L<p5-mop>, L<coretypes> or L<B::C>.
-
- use coretypes;
- my const int @a = (0..9);
- my const string %h
- = ('ok' => '1',
- 'bad' => '2');
+const packages allow compile-time optimizations of method calls.
+
+ use v5.18;
+ my const $a = 0;
+ my const @a = (0..9);
+ my const %h = ('ok' => '1',
+ 'bad' => '2');
+ const package foo {
+ ...
+ }
Why not as attribute C<my $var :const>?
@@ -126,7 +133,6 @@ typed variables.
const variables may be upgraded to its string or numeric representation.
They may be numified and/or stringified, strictly typed variables not.
-
my const $a = 1;
my const $s = "1";
my int $ti = 0;
@@ -224,7 +230,7 @@ which changes the passed value, use the ref syntax \$name
print $i;
=> 2
-See also <Method::Signatures>.
+See also L<Method::Signatures>.
=head3 Return type declarations
@@ -255,7 +261,6 @@ Old Variant (use typesafety)
Modern C-like variant
int sub function (int $i) {}
-
=head2 Changes & existing bugs
=head3 Can't declare subroutine entry in "my"
Please sign in to comment.
Something went wrong with that request. Please try again.