Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Generalising properties

7 views
Skip to first unread message

Paul Johnson

unread,
Oct 29, 2002, 5:19:59 PM10/29/02
to Perl 6 Language
OK, perl6-language is getting scary again ;-) So here's something else
to think about. Code coverage.

We don't have to worry about how to do it here. That's a problem for
internals, and they seem to be solving it quite well without my
interference at the moment, even if they are not aware of that.

But it's often nice to be able to provide information to the coverage
tool which it may not be able to figure out on its own. In most
coverage tools, this sort of information is bolted onto the language,
usually in the form of special comments. It would be nice to be able to
design something useful into Perl 6 from the start.

So I would like to see able to tag arbitrary information onto just about
everything, including files, packages, classes, subroutines, blocks,
control structures, statements, lines, expressions, variables and
whatever else I've forgotten about. Properties can be attached to some
of these. Can we generalise this at all?

Of course, the applicability of this is not limited to code coverage, so
it would be nice to have something as general and multi purpose as
possible.

The sort of data I'm thinking about includes:

- this statement should never be executed
- this class is a singleton
- these two conditional statements have the same condition
- the values that this variable can take are constrained by that variable
- these two subroutines are mutually exclusive - use one or the other

But I don't want language support for saying that, that seems to be a
problem for the applications that want the data, although I'd be glad to
be shown that I am wrong and that the language can support that in a
clean and concise way. Instead, I just want somewhere to hang arbitrary
data.

Thoughts?

--
Paul Johnson - pa...@pjcj.net
http://www.pjcj.net

Chromatic

unread,
Oct 29, 2002, 6:37:24 PM10/29/02
to perl6-l...@perl.org
On Tue, 29 Oct 2002 14:19:59 -0800, Paul Johnson wrote:

> So I would like to see able to tag arbitrary information onto just about
> everything, including files, packages, classes, subroutines, blocks, control
> structures, statements, lines, expressions, variables and whatever else I've
> forgotten about. Properties can be attached to some of these. Can we
> generalise this at all?

> Of course, the applicability of this is not limited to code coverage, so it
> would be nice to have something as general and multi purpose as possible.

> But I don't want language support for saying that, that seems to be a problem


> for the applications that want the data, although I'd be glad to be shown that
> I am wrong and that the language can support that in a clean and concise way.
> Instead, I just want somewhere to hang arbitrary data.

Dan started a thread about bytecode in p6i:

http://archive.develooper.com/perl6-i...@perl.org/msg13377.html

I jumped on the "arbitrary metadata" soapbox, and finally distilled my thoughts
down to this:

http://archive.develooper.com/perl6-i...@perl.org/msg13443.html

It sounds like we're thinking along the same lines. This would be very handy
for introspective tools (code coverage, refactoring browsers, IDEs...).

-- c

Paul Johnson

unread,
Oct 30, 2002, 7:13:31 AM10/30/02
to chro...@wgz.org, perl6-l...@perl.org


Yes, and this is the thread that insired me to post, or at least to post
now. As I mentioned, the internals support is coming along fine, but what
I'm concerned about here is support at the language level.

For example, using the coverage property:

sub check coverage(callable => $Debug && $OS ne "...")
{
my $v = shift;

if ($v > 5).coverage(id => my $cond_id = $Id++)
{
...
}

...

if ($v > 5).coverage(id => $Id++, same_as => $cond_id)
{
...
}

if (($a ŚŚ $b).coverage(truth_table => [[1, 1], [1, 0]],
comment => '$a and $b can't both be true') ŚŚ
($c && $d).coverage(truth_table => [[0, 1], [1, 1]],
comment => '$c and $d can't both be false'))
{
...
}

exec $something;

die("Whoops").coverage(coverable => 0);
}

Coming up with sensible small examples is not easy, but hopefully you get
the idea. How does the programmer tag the metadata onto the appropriate
construct?

0 new messages