Re: Is self a C pointer?
On 12/20/20 9:27 PM, Brad Gilbert wrote: It doesn't matter if it is a C pointer. Unless you are working on Moarvm, you should consider them arbitrary unique numbers. Like GUID. That said, yes I'm sure that they represent a location in memory. That explains it. Thank you! I used teh term "C pointer" as the Perl 5 grouches get pissed at you if you don't. They have "references" and will corrrect you instantly if you call their fancy reference pointer a pointer.
Re: Is self a C pointer?
On Sun, Dec 20, 2020 at 4:45 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > Hi All, > > In the following: > > Example 3: > > class PrintTest { > has Str $.Msg; > > method PrintMsg() { >print "self = <" ~ self.Msg ~ ">\n"; >print "self = <" ~ self.Str ~ ">\n"; > } > } > > my $x = PrintTest.new(Msg => "abc"); > > $x.PrintMsg > self = > self = > > > is "95224840" a C pointer? What is that thing? > > > Many thanks, > -T Hi Todd, Looks like you're just returning the Raku pointer. You get the same result printing "self" with-or-without .Str afterwards: class PrintTest { has Str $.Msg; method PrintMsg() { print "self = <" ~ self ~ ">\n"; print "self = "; dd self; print "self = "; dd self.WHAT; put ""; print "self = <" ~ self.Str ~ ">\n"; print "self = "; dd self.Str; print "self = "; dd self.Str.WHAT; put ""; print "self = <" ~ self.Msg ~ ">\n"; print "self = "; dd self.Msg; print "self = "; dd self.Msg.WHAT; } } my $x = PrintTest.new(Msg => "abc"); $x.PrintMsg; user@mbook~$ raku ./Todd_classes_1220_2020.p6 self = > self = PrintTest.new(Msg => "abc") self = PrintTest self = > self = "PrintTest<140382599051224>" self = Str self = self = "abc" self = Str user@mbook~$ If you look at the returns above, calling self with dd (first series) is actually more informative than stringifying (second series). HTH, Bill.
Re: Is self a C pointer?
It doesn't matter if it is a C pointer. Unless you are working on Moarvm, you should consider them arbitrary unique numbers. Like GUID. That said, yes I'm sure that they represent a location in memory. On Sun, Dec 20, 2020, 6:45 PM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > Hi All, > > In the following: > > Example 3: > > class PrintTest { > has Str $.Msg; > > method PrintMsg() { >print "self = <" ~ self.Msg ~ ">\n"; >print "self = <" ~ self.Str ~ ">\n"; > } > } > > my $x = PrintTest.new(Msg => "abc"); > > $x.PrintMsg > self = > self = > > > is "95224840" a C pointer? What is that thing? > > > Many thanks, > -T >
Is self a C pointer?
Hi All, In the following: Example 3: class PrintTest { has Str $.Msg; method PrintMsg() { print "self = <" ~ self.Msg ~ ">\n"; print "self = <" ~ self.Str ~ ">\n"; } } my $x = PrintTest.new(Msg => "abc"); $x.PrintMsg self = self = > is "95224840" a C pointer? What is that thing? Many thanks, -T