On Mon, 26 Jun 2017 02:02:22 -0700, ben-goldb...@hotmail.com wrote:
> This is a request for a new syntactic feature for perl6, a keyword
> named 'unlisp' or 'unbrace'.
> 
> This new keyword would act almost exactly like a '{', with the
> difference that when a matching '}' is found (or the end of file is
> reached),  an extra '}' is inserted.  If more than one 'unlisp'
> keywords occur in a given scope, then the end of scope acts as if
> there were a matching number of '}''s present.
> 
> This keyword would serve a similar purpose to 'unit', but would be
> much more generic.
> 
> One way that this could be used, where 'unit' would not work, would be
> something like:
> 
> unit package Foo;
> my package EXPORT::DEFAULT unlisp;
> our sub bar {...}; # gets exported.
> my sub baz {...}; # doesn't get exported.
> 
> At present, 'unit' doesn't combine with 'my'.
> 
> It would be even cooler if 'unlisp', instead of acting like a '{'
> itself, were required to be placed at the beginning of a statement,
> and transformed the next appearing ';' into a '{' ... this would make
> it more like the current 'unit' keyword, but this might be harder to
> parse.

The motivating example included here isn't even slightly persuasive, since it's 
possible to write it as just:

unit package Foo;
sub bar is export {...}
sub baz {...}

But that aside, braces being required rather than having dangling syntax is 
considered a syntactic feature of Perl. The `unit` declarator is worth a 
special case because it saves a level of indentation for the entire file. And 
since it means "take the entire rest of the file as the body", there's no magic 
going on with regard to handling the end. Furthermore, that curly braces mean 
scope is a very consistent design rule throughout Perl 6. Something that 
magically inserts them doesn't fit with that.

This is probably possible to do as a module, but I have a very hard time seeing 
a feature like this making the core language. It just goes against the grain of 
the language design. Thus, rejected.

/jnthn

Reply via email to