Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Metamodel::Versioning #2968

Merged
merged 1 commit into from Aug 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
75 changes: 75 additions & 0 deletions doc/Type/Metamodel/Versioning.pod6
@@ -0,0 +1,75 @@
=begin pod :kind<Type> :subkind<role> :category<metamodel>

=TITLE role Metamodel::Versioning

=SUBTITLE Metaobjects that support versioning

role Metamodel::Versioning { ... }

L<Metamodel|/language/mop> role for (optionally) versioning metaobjects.

When you declare a type, you can pass it a version, author, and/or API and get
them, like so:

=begin code :lang<perl6>
class Versioned:ver<0.0.1>:auth<github:Kaiepi>:api<1> { }

say Versioned.^ver; # OUTPUT: «v0.0.1␤»
say Versioned.^auth; # OUTPUT: «github:Kaiepi␤»
say Versioned.^api; # OUTPUT: «1␤»
=end code
Kaiepi marked this conversation as resolved.
Show resolved Hide resolved

This is roughly equivalent to the following, which also sets them explicitly:

=begin code :lang<perl6>
BEGIN {
class Versioned { }
Versioned.^set_ver: v0.0.1;
Versioned.^set_auth: 'github:Kaiepi';
Versioned.^set_api: <1>;
}

say Versioned.^ver; # OUTPUT: «v0.0.1␤»
say Versioned.^auth; # OUTPUT: «github:Kaiepi␤»
say Versioned.^api; # OUTPUT: «1␤»
=end code

=head1 Methods

=head2 method ver

method ver($obj)

Returns the version of the metaobject, if any, otherwise returns L<Mu|/type/Mu>.
Copy link

Choose a reason for hiding this comment

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

With recent changes something like the following could be added to this:

For CORE classes the method would report language version they were compiled with. For example:

use v6.d; say PseudoStash.^ver; # 6.c because this is where the class is actually defined.
use v6.e.PREVIEW; say PseudoStash.^ver; # 6.e

Actually, the version is set by set_ver method, but I'm not sure if it worth mentioning here because it is only happens when COREs are compiled and thus is only relevant to core developers.


=head2 method auth

method auth($obj)

Returns the author of the metaobject, if any, otherwise returns an empty string.

=head2 method api

method api($obj)

Returns the API of the metaobject, if any, otherwise returns an empty string.

=head2 method set_ver

method set_ver($obj, $ver)

Sets the version of the metaobject.

=head2 method set_auth

method set_auth($obj, $auth)

Sets the author of the metaobject.

=head2 method set_api

method set_api($obj, $api)

Sets the API of the metaobject.

=end pod