Forums

Implicit line continuations for contents of unclosed Parens

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Implicit line continuations for contents of unclosed Parens

Postby hopscc » Fri Jul 18, 2008 4:14 am

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?
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Implicit line continuations for contents of unclosed Parens

Postby Charles » Tue Jul 22, 2008 5:17 pm

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.
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: Implicit line continuations for contents of unclosed Parens

Postby hopscc » Tue Jul 22, 2008 7:15 pm

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.
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand

Re: Implicit line continuations for contents of unclosed Parens

Postby Charles » Tue Jul 22, 2008 7:38 pm

I was thinking that if the line ends on an operator then it's pretty obvious that it continues.
Charles
 
Posts: 2510
Location: Los Angeles, CA

Re: Implicit line continuations for contents of unclosed Parens

Postby hopscc » Tue Jul 22, 2008 8:30 pm

Yah - to the tokeniser too it seems
hopscc
 
Posts: 631
Location: New Plymouth, Taranaki, New Zealand


Return to Discussion

Who is online

Users browsing this forum: No registered users and 2 guests

cron