Re: Forcing a Positional role

2017-10-29 Thread Fernando Santagata
On Sat, Oct 28, 2017 at 1:58 PM, Simon Proctor wrote: > multi method ASSIGN-POS( $index, $new ) { > @!arr[$index] = $new; > } > This solves my problem with the first implementation, thank you for pointing me to the ASSIGN-POS method. Now what's left for me to understan

Re: Forcing a Positional role

2017-10-28 Thread Simon Proctor
Maybe a given block then? I generally go for brute force first. On Sat, 28 Oct 2017, 9:21 pm Fernando Santagata, wrote: > Yes, the size of the object would change. In any case, I can't use a Perl6 > Array in a NativeCall class, so the point is moot. > > The problem is that that C library exposes

Re: Forcing a Positional role

2017-10-28 Thread Fernando Santagata
Yes, the size of the object would change. In any case, I can't use a Perl6 Array in a NativeCall class, so the point is moot. The problem is that that C library exposes an API, whose main structure contains an array of five pointers to another kind of struct. It is not a pointer to an array of poi

Re: Forcing a Positional role

2017-10-28 Thread Simon Proctor
Ahhh.. H. Even with the array as a private variable? On Sat, 28 Oct 2017, 8:41 pm Fernando Santagata, wrote: > Hello Simon, > Thank you for your reply. > > I would use an array if I hadn't the constraint that in a NativeCall class > I can't use a Perl6 Array, just a CArray. > Anyway I couldn

Re: Forcing a Positional role

2017-10-28 Thread Fernando Santagata
Hello Simon, Thank you for your reply. I would use an array if I hadn't the constraint that in a NativeCall class I can't use a Perl6 Array, just a CArray. Anyway I couldn't add a CArray to the class, because it would change its size and I need to pass the reference to that class to a C function.

Re: Forcing a Positional role

2017-10-28 Thread Simon Proctor
Here's my very naive way of doing it. class A does Positional { has $.a0 is rw; has $.a1 is rw; has $.a2 is rw; has $.a3 is rw; has $.a4 is rw; has $.a5 is rw; has @!arr; method TWEAK { @!arr[0] := $.a0; @!arr[1] := $.a1; @!a