develooper Front page | perl.perl6.users | Postings from January 2021

Extra . needed

Thread Next
Richard Hainsworth
January 3, 2021 18:30
Extra . needed
Message ID:
I was playing with classes and adding a closure to an attribute.

I discovered that to call a closure on object I need `.()` rather than 
just `()`. See REPL below.

Welcome to 𝐑𝐚𝐤𝐮𝐝𝐨™ v2020.12.
Implementing the 𝐑𝐚𝐤𝐮™ programming language v6.d.
Built on MoarVM version 2020.12.

To exit type 'exit' or '^D'
 > class A { has &.f = -> { 'xyz' }}
 > my A $a .=new => ->  { #`(Block|94272504746848) ... })
 > say $a.f()
->  { #`(Block|94272504749656) ... }
 > say $a.f.()

I was wondering whether it was intended for `()` to return something 
other than `.()`?

My first thought would be that `.()` would have the same syntactic sugar 
as `.[]` on an Array object.

I looked in the Documentation and in Classes found

inside class Task.

So I think there may be something a bit wrong. Or is this an artifact of 

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About