Skip to content

bracket readability #5

Open
Open

Description

@chayleaf

(Note that I'm not a lisp programmer, it's the first time I'm reading lisp, however I am interested in using scripting for games and lisp's powerful data model)

Lisp's opening brackets look readable. However, the closing brackets - )))))), are hard to understand without coloring each bracket pair differently. When I saw it, I immediately thought - can't more bracket types be used? As it turns out, they can - for example, Racket lang accepts all bracket types. Can the same be applied here? I think it would greatly improve general readability, at least for beginners.

Activity

  1. fleabitdev commented on Jun 12, 2020

    @fleabitdev
    Owner

    In GameLisp, unlike most Lisps, the different bracket types have different semantic meanings. () is general-purpose, [] is for accessing an element of a collection, and {} is for string escaping.

    (let x [ar -1])
    (prn "the last element is {x}")
    

    )))))) is a very real problem, so I'm going to leave this issue open to gather suggestions for how the problem might be mitigated. So far, I'm considering:

    • Explicitly suggesting in the documentation that the user should switch on bracket-matching in their text editor. Making sure this is switched on for every syntax-highlighting scheme which we develop, where possible.

      • Sublime Text 3 has a WONTFIX bug which causes brackets fail to match if they're separated by more than a few dozen lines. This is a real usability issue. Our documentation should probably recommend the BracketHighlighter plugin.
    • The roadmap already mentions the possibility of augmenting the parser so that it can try to pinpoint the location of mismatched brackets, based on whitespace. Currently, it provides a vague "unterminated arr" error message which is scoped to the entire source file.

    • Document this pattern for splitting up trailing brackets in class clauses:

    (defclass Class
      (fsm
        (state State
        
          (quite-indented-clause
            (first
              (second
                (third))))
          
          ; end of State
          #n)
        
        ; end of fsm
        #n))
    
  2. changed the title [-]different brackets?[/-] [+]bracket readability[/+] on Jun 13, 2020
  3. yurapyon commented on Jun 15, 2020

    @yurapyon

    There are also plenty of Lisp editing tools that make the task of working with parens less of a hastle.
    One such that I use is parinfer, https://github.com/shaunlebron/parinfer, which allows me to never really worry about parens and just deal with indentation. Emac's ParEdit is ubiquitous in helping deal with parens. I used to use the method of splitting up brackets, but parinfer has changed that haha. I really can't recommend it enough.

    As a frequent Scheme user, I'd argue that only allowing parens enhances readability. The more acquainted you get with it, the more the plain syntax of just atoms and parens starts to read like English. Lispers have dealt with the strings of parens since its inception, its just a matter of getting used to them, which - I'll be the first to admit - is a big change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions