-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Perl new classes system
Perl got a new builtin class support which brought new keywords like `class`, `method` and `field`, being that some support versioning and attributes. This commit adds the new keywords with the additional features they support (eg. attributes and version), alongside their markup test.
- Loading branch information
Showing
3 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<span class="hljs-keyword">use</span> <span class="hljs-number">v5.38</span>; | ||
|
||
<span class="hljs-keyword">use</span> Object::Pad; | ||
|
||
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Example</span>::<span class="hljs-title">Subclass</span><span class="hljs-attribute"> :isa</span>(<span class="hljs-title">Example</span>::<span class="hljs-title">Base</span> <span class="hljs-number">2.345</span>) </span>{ | ||
<span class="hljs-keyword">field</span> $_config<span class="hljs-attribute"> :param</span><span class="hljs-attribute"> :reader</span><span class="hljs-attribute"> :writer</span>; | ||
<span class="hljs-keyword">field</span> $_name<span class="hljs-attribute"> : param</span> = <span class="hljs-string">'Test'</span>; | ||
|
||
<span class="hljs-function"><span class="hljs-keyword">method</span> <span class="hljs-title">test</span>() </span>{ | ||
$_name == <span class="hljs-string">'Test'</span> ? <span class="hljs-string">'y'</span> : <span class="hljs-string">'n'</span>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use v5.38; | ||
|
||
use Object::Pad; | ||
|
||
class Example::Subclass :isa(Example::Base 2.345) { | ||
field $_config :param :reader :writer; | ||
field $_name : param = 'Test'; | ||
|
||
method test() { | ||
$_name == 'Test' ? 'y' : 'n'; | ||
} | ||
} |