0

I was coding today and the thought occurred to me: why is dynamic scaling of the relative sizes of nested parentheses/brackets/curly braces not already a common feature of code editors?

One often has layers of functions nested one inside the other

zip(range(len(some_list)), range(len(some_other_list)))

or functions called on containers which may contain complicated elements

foo({bar(1, ("A", "B", "C")): [1,2,3], bar(2, ("x", "y", "z"): [4,5,6]})

or maybe just long math expressions.

If one was writing out such expressions on a whiteboard one would likely scale the sizes of successive pairs of parentheses to keep track of the scope one was currently at, with the outermost parentheses having the largest size and size incrementally decreasing as we progress to inner scopes.

Is anyone aware of any code editors that do this (or failing this, aware of any justification for not doing so)?

  • It's a good, and relevant, question, but I don't know if there is an objective answer to this. (Aside from there being published papers discussing the topic.) – Mayo Apr 7 '16 at 14:30
  • I would certainly appreciate such an answer pointing out some of those papers! – Josh Chen Apr 7 '16 at 14:42
  • Oh. My mistake. I didn't make myself clear. I've never seen any paper that discussed this. And without a source such as this, or personal experience from working on such a project, there isn't an answer to your question. – Mayo Apr 7 '16 at 14:50
  • Imo, using different colors would be a better solution, different sizes will throw off line spacing making it harder to read, plus most editors don't really implement "font-size" of the code. – DasBeasto Apr 7 '16 at 15:01
  • Better than different colours, different intensities of brightness. – Confused Apr 7 '16 at 15:02
1

In my opinion (not based on fact, but I doubt you'll find many answers to this that are), the text editors would appear to get very messy very quickly.

Being able to line up everything and organize your code increases readability. One of the most common tips for increasing readability is consistent indentation. Unpredictable horizontal spacing impairs readability. I can only imagine that unpredictable vertical spacing would do the same.

Additionally, handwritten expressions don't often have as deep of a parenthetical nesting as what is quite common in programming. What may be a useful technique for handwritten expressions would not necessarily be wise to implement for text editors (you could wind up with some huge parentheses...).

  • Said like a true Lisp proponent ;) – Confused Apr 7 '16 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.