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

Implement $=data for Pod data blocks #3029

Open
p6rt opened this issue Jan 16, 2013 · 6 comments
Open

Implement $=data for Pod data blocks #3029

p6rt opened this issue Jan 16, 2013 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Jan 16, 2013

Migrated from rt.perl.org#116419 (status was 'open')

Searchable as RT116419$

@p6rt
Copy link
Author

p6rt commented Jan 16, 2013

From kevin@dawson10.plus.com

Hi All,

ticket as requested by FROGGS

the info in -> http://perl6.org/compilers/features

relating to Lexing and Parsing - Pod implies all works,

But This is not the case

Data Blocks from - http://perlcabal.org/syn/S26.htm

  Data blocks <http://perlcabal.org/syn/S26.html#___top>

Named Pod blocks whose typename is |data| are the Perl 6 equivalent of
the Perl 5 |__DATA__| section. The difference is that |=data| blocks are
just regular Pod blocks and may appear anywhere within a source file,
and as many times as required.

There is a corresponding variable, |$=data|, from which each |=data|
block can be retrieved. |$=data| holds an object that does both the
Associative and Positional roles.

Each |=data| block can be given a |​:key| option, to name it. The
contents of any |=data| block with a key are accessible (as a single
string) via the Associative aspect of |$=data| object. For example​:

  =begin data :key<Virtues>
  Laziness
  Impatience
  Hubris
  =end data

  say 'The three virtues are​:';
  say $=data<Virtues>;

The contents of any |=data| block that does not have a |​:key| are
accessible (as a single string) via the Positional aspect of |$=data|.
Unkeyed |=data| blocks are stored in the same order they appear in the
file. For example​:

  say 'The second anti_Virtue is​: ', $=data[1];

  =data Industry
  =data Patience
  =data Humility

Note that, as the preceding example illustrates, because Pod is a
compile-time phenomenon, it is possible to specify |=data| blocks
/after/ the point in the source where their contents will be used
(provided they're not being used in a |BEGIN|, of course).

When |$=data| itself is stringified, it returns the concatenation of all
the unkeyed |=data| blocks the parser has seen.

|=data| blocks are never rendered by the standard Pod renderers.

We Now Generate the following Output​:

$ perl6 data_blocks.p6
===SORRY!===
Variable $=data is not declared
at data_blocks.p6​:10
------> say $=data<Virtues>?;
  expecting any of​:
  postfix

regards
bowtie

@p6rt
Copy link
Author

p6rt commented Jan 16, 2013

From kevin@dawson10.plus.com

use v6;

=begin data :key<Virtues>
Laziness
Impatience
Hubris
=end data

say 'The three virtues are​:';
say $=data<Virtues>;

say 'The second anti_Virtue is​: ', $=data[1];

=data Industry
=data Patience
=data Humility

@p6rt
Copy link
Author

p6rt commented Jan 16, 2013

From bowtie@cpan.org

https://github.com/perl6/features/blob/master/features.json#L908

"status" : "r+ n+- (parsing only, no $=pod)",

could be changed to

"status" : "r+- n+- (parsing only, no $=pod)",

regards
or
data blocks don't live in S26

I don't know

@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

@usev6 - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Feb 7, 2015

From @usev6

I'll modify the feature matrix at http://perl6.org/compilers/features to reflect the missing implementation of $=data for Pod data blocks.

@JJ
Copy link

JJ commented Dec 30, 2020

Message now is:

Pod variable $=data not yet implemented. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants