2 ms·
> For example, people will draw ASCII pictures for simple diagrams in the code and comments. In some of my code (I work with chemistry) I listed the element sym
by gkya 13y ago
> For example, people will draw ASCII pictures for simple diagrams in the code and comments. In some of my code (I work with chemistry) I listed the element symbols laid out as a periodic table-like grid. This only works with fixed width fields.
> And of course multi-line parameters are usually continued inside of the leading '(', as in this forward declaration:
Thus did I express in the initial post, that I assume we do not do this kind of alignments, and the interval of indentation is fixed, i.e. is always a multiple of a given number of spaces, or exactly one tab character.
- dalke 13y agoI gave that example for two reasons. One is that it's not possible to assume the world can change. There's a big installed base. The second is that your solution - fixed indentation levels, etc - doesn't work for this case. Or as a challenge, what's your better way of writing this yacc-style BNF in a proportional font? atom_symbols ::= 'H' | 'He' |'Li'|'Be'| 'B' |'C' |'N' |'O' |'F' |'Ne' |'Na'|'Mg'| 'Al'|'Si'|'P' |'S' |'Cl'|'Ar' |'K' |'Ca'|'Sc'|'Ti'|'V' |'Cr'|'Mn'|'Fe'|'Co'|'Ni'|'Cu'|'Zn'|'Ga'|'Ge'|'As'|'Se'|'Br'|'Kr' |'Rb'|'Sr'|'Y' |'Zr'|'Nb'|'Mo'|'Tc'|'Ru'|'Rh'|'Pd'|'Ag'|'Cd'|'In'|'Sn'|'Sb'|'Te'|'I' |'Xe' |'Cs'|'Ba'| 'Hf'|'Ta'|'W' |'Re'|'Os'|'Ir'|'Pt'|'Au'|'Hg'|'Tl'|'Pb'|'Bi'|'Po'|'At'|'Rn' |'Fr'|'Ra'| 'Rf'|'Db'|'Sg'|'Bh'|'Hs'|'Mt'|'Ds'|'Rg' |'La'|'Ce'|'Pr'|'Nd'|'Pm'|'Sm'|'Eu'|'Gd'|'Tb'|'Dy'|'Ho'|'Er'|'Tm'|'Yb'|'Lu' |'Ac'|'Th'|'Pa'|'U' |'Np'|'Pu'|'Am'|'Cm'|'Bk'|'Cf'|'Es'|'Fm'|'Md'|'No'|'Lr'; Every example I can think of is uglier, and harder to understand. The only solution is that everyone switches to a source code encoding which includes enough presentation capabilities that it supports embedded tables. I don't see that happening any time soon. Do you have a better suggestion of how to lay this out in some alternative environment?
- gkya 13y agoI do not have a counter-example, and think that in this case, a monospaced font is necessary for good presentation. However, I'd not format this code in this shape in the first place, instead list them linearly with line breaks where due: atom_symbols ::= 'H' | 'He' ... 'Na' | 'Be' ...; This way it is easier to edit, automatically wrap (not meaning that the periodic table will change drastically soon, but this might have been a table of sth. else) and read the snippet. This is more of a matter of personal delight though.
- dalke 13y agoNow you're throwing away data in preference of your own beliefs. That's a dangerous path. Of course if this is a table of something else then it might be okay to use a different formatting. But that I could easily give a counter-example, suggests that there are plenty of counter-examples. You argue that a linear list, without spacing, has advantages. My assertion is that you don't have the experience to make that judgement. Anyone using this layout will have chemistry experience, and often decades of practice of looking at the periodic table in standard form. When I consider at your suggested layout, I find it a bit jarring. For one, the symbols you wrote are out-of-order, which means it's hard to infer some information from the table. For example, what is the age of the this instance of the table? A chemist knows, from experience with the standard periodic table layout, and my use of that layout, that Rg is the newest element on the list. This immediately places it as a pre-2009 table, which means I should update it. Here's an example from Python heapq.py implementation, rewritten slightly to work in HN (I switched from triple-quoted strings to '#' comments): # The strange invariant above is meant to be an efficient memory # representation for a tournament. The numbers below are `k', not a[k]: # # 0 # # 1 2 # # 3 4 5 6 # # 7 8 9 10 11 12 13 14 # # 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 # # # In the tree above, each cell `k' is topping `2*k+1' and `2*k+2'. This is a tree structure layout in ASCII. It's useful information, and it can't easily be structured or represented in a proportional font.