Hi, when you install latest MoarVM, you can do this: $ perl6 -e 'use NativeCall; class Foo is repr<CStruct> { has str $.bar is rw }; my $foo = Foo.new(bar => "bar"); say $foo; $foo.bar = "baz"; say $foo' Foo.new(bar => "bar") Foo.new(bar => "baz")
Note the lowercase str type. The normal Str type can be set by binding to the $!bar attribute from within the class, but not from the outside via arguments to .new sadly. Cheers, FROGGS Am 02.06.2015 um 19:38 schrieb Douglas E. Miles: > Hi all! > > I just started learning Perl 6 about 5 days ago, so I may not know > what I'm talking about, but I may have found a bug. I posted to #perl6 > with my original code, and raydiak and timotimo were nice enough to > golf it down for me: > > Str in CStruct blows up: > $ perl6 > > use NativeCall; class Foo is repr('CStruct') { has Str $.str }; my > $foo = Foo.new(str => 'bar'); > Cannot modify an immutable Str > in block <unit> at <unknown file>:1 > in any <unit-outer> at <unknown file>:1 > > int32 in CStruct works fine: > $ perl6 > > use NativeCall; class Foo is repr('CStruct') { has int32 $.i }; my > $foo = Foo.new(i => 42); > Foo.new(i => 42) > > say $foo.i > 42 > > Please let me know if I'm doing something wrong, or if this is a legit > bug. Thanks!