Half a croissant, on a plate, with a sign in front of it saying '50c'
h a l f b a k e r y
"More like a cross between an onion, a golf ball, and a roman multi-tiered arched aquaduct."

idea: add, search, annotate, link, view, overview, recent, by name, random

meta: news, help, about, links, report a problem

account: browse anonymously, or get an account and write.

user:
pass:
register,


                                   

Please log in.
Before you can vote, you need to register. Please log in or create an account.

Parentheses tracker

This will help remind you to close all your parentheses.
  (+10, -2)(+10, -2)
(+10, -2)
  [vote for,
against]

In programming, typing mathematical formulas can be a nuisance because of all of the parentheses. How do you keep track of them all?

Also, some programming languages, such as C and Lisp, are practically parentheses-based! (Well, in C, actually it's braces, but it's the same principle.)

What would be good is a compiler that would show little numbers or something above parentheses to keep track of the levels. Or different colours for the text within. Or do away with parentheses altogether, instead saying "Level 1", "Level 2", etc.

As for indentation to keep track of levels, in theory it might be great, but in practice it royally sucks, because your lines are all shoved over to the right, and the lines have to be really short to fit on the screen!

juuitchan3, Jun 29 2002

PT ~bz [bristolz, Nov 11 2005, last modified Feb 05 2006]

Maybe something like this? http://www.sloth.or...offeg/highlight.png
[egnor, Jul 01 2002, last modified Oct 04 2004]

Or this. http://crimsoneditor.com/
[angel, Nov 11 2005]

[link]






       How about an end of line "balancing bullet", pointing left (too many closed parentheses in argument) or __
right (need more closed parentheses in argument) that must be resolved before an end of text is encountered?
reensure, Jun 29 2002
  

       Partially baked in many editors, which automatically highlight the corresponding closing brace when the cursor is on the opening brace.   

       The PythonWin environment for Python does this particularly well; I've been known to edit C code with it to get the balancing on particularly hairy macro definitions right.   

       (As an aside, Python uses indentation to _explicitly_ denote scope: no scoping braces or begin/end statements. Seems odd to begin with but feels very natural very quickly...)
JKew, Jun 29 2002
  

       Well, I have seen math engines which track parenthesis pairs by color. One that I've seen will even show the innermost not-yet-closed parenthesis in boldface.   

       As for text editors for programming languages, there are thousands (possibly millions) of those available that do various forms of context highlighting. One of those might already do something functionally equivalent to subscripting the opening and closing {braces|brackets|parentheses|angles}. If not, it shouldn't be too big of a leap to include such a feature.   

       By the way, I feel your pain when it comes to indentation eating up your real estate. I usually indent only 2 or at most 3 spaces, and then only inside the braces (not a level for the braces and another for the contents, as some do). But I still see 1/3 to 1/2 of each line get wasted on white space. I like hard copy backups so I avoid lines over 80 characters wide.
BigBrother, Jun 29 2002
  

       I wanted something similar to this for html braces (see Nested Tages HTML Editor) and am trying to persuade Mark, the author of Araneae (a HTML editor - see araneae.com) to include this in his next release. Since he's still accepting feature requests for version 5 you may want to suggest parenthesis tracking too.
st3f, Jul 01 2002
  

       Syntax error line 324: Expected ")"
waugsqueke, Jul 01 2002
  

       I was just thinking about this very topic for C-based programming languages that use brackets. How about automatic closing bracket insertion, combined with highlighting?   

       I like the idea of the Level 1... etc. and the "Nested Tags..." idea and was thinking: how about having levels be arbitrarily named by the user as a word label or even a symbol and then ended with a semicolon; as usual. [EXAMPLE: Level n;] After the initial labelling, something like a /level n; is inserted automatically and you just program in between. It would be more intuitive than mere brackets, and maybe the compiler could automatically transform this back to ordinary nested bracket code for the sake of space. Highlighting could be incorporated.
polartomato, Jul 02 2002
  

       When I learnt to program C, we were taught to type the opening brace, then the closing brace, and then fill in the stuff inbetween. This stops any annoying problems with forgetting to close your braces.
pottedstu, Jul 02 2002
  

       Ugh. Practicality raises its ugly head yet again.
polartomato, Jul 02 2002
  

       [pottedstu]: That's the way I do it too;, also for constructions that require a closing 'tag', whether VB, HTML, or whatever.
angel, Jul 02 2002
  

       Something MS Visual Studio .NET should do in addition to showing squigleys(sp?)
Porsche911, Jun 27 2004
  

       I would like to see indicators in the status bar (like the OVR, TRK, CAP, REC things in a word processor) -- but these would say "FOR" "WITH" "IF", etc. to remind you what clauses you're in the middle of.
phundug, Nov 10 2005
  

       I too have adopted the "Shift-9-0-leftarrow" method of parentheses within my code. It's become so automatic that I don't even think about it anymore.
Freefall, Nov 10 2005
  

       Too funny, [bristolz]!
jurist, Nov 11 2005
  

       Cheers for bristolz tractor!
DesertFox, Nov 12 2005
  
      
[annotate]
  


 

back: main index

business  computer  culture  fashion  food  halfbakery  home  other  product  public  science  sport  vehicle