Skip Menu |
Report information
Id: 131174
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: david.warring <david.warring [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Wed, 19 Apr 2017 15:33:36 +1200
From: David Warring <david.warring [...] gmail.com>
Subject: [NYI] Atrribute Introspect shape
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 495b
AFAIK there's currently no way of introspecting the shape of a Class attribute that's a native shaped array.

I'd like this feature for the Native::Packing module. For example to interpret:

class C {
    has byte @.gif-header[6];
    has uint16 $.width;
    has uint16 $height;
}

At the moment, I just can't determine the size of shaped native arrays, such as @.gif-header above:
say .type, .container
    for C.^attributes;
(Positional[byte])(array[byte])
(uint16)(uint16)
(uint16)(uint16)

RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 874b
On Tue, 18 Apr 2017 20:34:15 -0700, david.warring wrote: Show quoted text
> AFAIK there's currently no way of introspecting the shape of a Class > attribute that's a native shaped array. > > I'd like this feature for the Native::Packing module. For example to > interpret: > > class C { > has byte @.gif-header[6]; > has uint16 $.width; > has uint16 $height; > } > > At the moment, I just can't determine the size of shaped native arrays, > such as @.gif-header above: > > say .type, .container > for C.^attributes; > > (Positional[byte])(array[byte]) > (uint16)(uint16) > (uint16)(uint16)
Seems .container does have method .shape, but it returns a Whatever: class C { has byte @.gif-header[6]; has uint16 $.width; has uint16 $height; } say .container.shape for C.^attributes[0]; # (*) dd C.new.gif-header.shape; # (6,) my byte @z[6]; dd @z.shape; # (6,)
I've added a fudged test to S12-introspection/attributes.t that the container shape is as declared; not a Whatever. On Wed, 19 Apr 2017 03:14:35 -0700, cpan@zoffix.com wrote: Show quoted text
> On Tue, 18 Apr 2017 20:34:15 -0700, david.warring wrote:
> > AFAIK there's currently no way of introspecting the shape of a Class > > attribute that's a native shaped array. > > > > I'd like this feature for the Native::Packing module. For example to > > interpret: > > > > class C { > > has byte @.gif-header[6]; > > has uint16 $.width; > > has uint16 $height; > > } > > > > At the moment, I just can't determine the size of shaped native arrays, > > such as @.gif-header above: > > > > say .type, .container > > for C.^attributes; > > > > (Positional[byte])(array[byte]) > > (uint16)(uint16) > > (uint16)(uint16)
> > > Seems .container does have method .shape, but it returns a Whatever: > > class C { > has byte @.gif-header[6]; > has uint16 $.width; > has uint16 $height; > } > say .container.shape for C.^attributes[0]; # (*) > dd C.new.gif-header.shape; # (6,) > > my byte @z[6]; > dd @z.shape; # (6,)


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org