Civet icon indicating copy to clipboard operation
Civet copied to clipboard

Indented declarations

Open edemaine opened this issue 2 years ago • 1 comments

I propose to allow Nested forms of declarations var/let/const/import/export/using. This makes it feel more consistent with other Nested support (e.g. class/interface).

var
  one = 1
  two = one + 1
let
  three = two + 1
  four = three + 1
const
  five = four + 1
  six = five + 1
import
  * as foo from 'foo'
  {bar} from 'bar'
export
  a = 5
  {b, c}
using
  a = foo()
  b = bar()

Basically the proposal is to make the commas between declarations automatic in the nested case. Of course, for import the heading is optional, but it might be nice organizationally to have an explicit import block. For let and const this is an alternative to our existing shorthand .= and :=.

Based on similar features in Nim

edemaine avatar Jul 19 '23 15:07 edemaine

This is probably even simpler than https://github.com/DanielXMoore/Civet/pull/677/files

STRd6 avatar Sep 03 '23 00:09 STRd6