develooper Front page | perl.perl6.users | Postings from October 2020

Re: Brace interpolation in strings creates a new scope?

Thread Previous
Patrick R. Michaud
October 26, 2020 19:25
Re: Brace interpolation in strings creates a new scope?
Message ID:
On Mon, Oct 26, 2020 at 08:04:21PM +0100, Elizabeth Mattijsen wrote:
> > On 26 Oct 2020, at 18:40, Sean McAfee <> wrote:
> > Is this the intended behavior?  The doc page on quoting constructs 
> > just says that values can be interpolated with braces, but (at least 
> > to my eyes) doesn't suggest that this involves creating a new scope, 
> > or a new function, or however it is that this happens.
> I guess we need to update the documentation.  But the braces inside a 
> double quoted string *do* create a new scope, causing the behaviour of 
> ++$ that you have seen.

In general Raku tries to avoid special cases... so I think that braces pretty much _always_ introduce a new scope.  I can't think of any exceptions at the moment, except for *maybe* when they are used as a hash constructor.  (And perhaps not even there.)

Of course I could be mistaken in this... but as a general rule, in language design there's been an effort to keep things consistent so that we don't have to say things like "braces create a new scope except when used in string interpolation" etc.


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