koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.26k stars 162 forks source link

Indentation based folding + {}-folding -- is bad #231

Closed Alexey-T closed 2 years ago

Alexey-T commented 2 years ago

It's virtually impossible to write good syntax file for CudaText which will find both

bad design of language syntax! sad! It must be either 1st or 2nd, the mix is bad!

Alexey-T commented 2 years ago

(No problem to find the beginning of a block, it's very hard to find ending of it for BOTH cases. Hence the problem to show code-tree with NESTING.)

daanx commented 2 years ago

Hi @Alexey-T ; thank for your work on CudaText and I agree the use of a layout rule makes it harder for editors. However, this is also the case for many other languages, like JavaScript, Haskell, Scala, Python, Go, etc. Just like Haskell, explicit braces are always allowed and the layout rule just elaborates a program into one with explicit braces and semicolons everywhere. The layout rule for koka is quite nice though in comparison as it can be specified as a separate pass between lexing and parsing with no dependencies on the context-free grammar.

I agree though, it's tricky for an editor; syntax highlighting can be done independently of layout, but for scopes / code-tree you would need to either use a language service, or perform the layout elaboration.