Page 1 of 1

Implicit line continuations for contents of unclosed Parens

PostPosted: Fri Jul 18, 2008 4:14 am
by hopscc
Like Cobra Python is mainly line based but this is alleviated by supporting an implicit line continuation
for an expression with unclosed/unbalanced parentheses. This is extremely convenient.

Cobra already has (undoc unmentioned?) support for this for array, list and dictionary literals e.g.
Code: Select all
 a = {  'a':1,
       'b':2,
       'c':3,
    }
 b = [ 1,
      2,3,
      4,
    ]

 c = @[
         'a',
         'b','c',
         'd',
     ]

compiles fine

Theres supporting (spaceAgnostic) coding existing for () enclosed method calls (currently not enabled).
I dont know what the issues may be with supporting implicit line continuation with arbitrary paren enclosed expressions but
it would ease code layout (avoiding a major area of pathologically long lines) and/or line continuation clutter
if at minimum the above code for method calls were enabled and the same support provided on method (and signature) definitions
allowing something like
Code: Select all
               .foo('argument Number 1',
                       'argument Number2',
                       'aregularArgument number3' )
...

                def foo(arg1 as String,
                           arg2 as String,
                           arg3 as String  ) is shared
                        print "in foo"
                        # do something
                        print 'foo done'

i.e multi lines for call args and parameter declarations.

comments?

Re: Implicit line continuations for contents of unclosed Parens

PostPosted: Tue Jul 22, 2008 5:17 pm
by Charles
I totally support this idea. Just haven't gotten to it. Patches are welcome.

I'm also toying with the idea that a line that ends with a binary operator such as + or and also implies line continuation.

Re: Implicit line continuations for contents of unclosed Parens

PostPosted: Tue Jul 22, 2008 7:15 pm
by hopscc
It just so happens I have a patch I prepared earlier
I'll open a ticket.

It turns out it almost falls out to allow expressions to continue implicitly across multiple lines (until completed).
I had to add some checks to limit it to doing so only inside parenthesized exprs......

I'm undecided whether its desirable to allow continuation til completion or not.

Re: Implicit line continuations for contents of unclosed Parens

PostPosted: Tue Jul 22, 2008 7:38 pm
by Charles
I was thinking that if the line ends on an operator then it's pretty obvious that it continues.

Re: Implicit line continuations for contents of unclosed Parens

PostPosted: Tue Jul 22, 2008 8:30 pm
by hopscc
Yah - to the tokeniser too it seems