[SM-Discuss] Request for comments - formating in spells

Vlad Glagolev stealth at sourcemage.org
Tue Jul 22 12:27:23 EDT 2008


Uhm, I'm against introducing more tabs too. They should stay as they are only in HISTORY, but
nowhere else. Why? Because most of our spells and sorcery code (which is maintaned and get
improved(!) by Jaka) are based on spaces-policy.

Next: this nice discussion was set afire by my last (by that time) commit about udev, ok, I'll
try to explain. It's really hard to fix the things and keep the line with formatting
"as it was left" (a.k.a. "unreadable", well, it's subjective, so enjoy to miss this word :P).
So when I fix the spell I automatically correct the syntax of the line. Yes, if the spell is so
ancient and there are not so many changes to do with it (and not so many different files to
touch), I'll try to separate the fixes from my "cleanups", I understood you, Jaka.

Next one: about my "cleanups". I reduce the space usage: as ryuji said, "I don't wanna go
through the jungles of spaces to fix the stuff". Everytime you change the line -- you must
change the alignment of the 3-4 above and below lines (or even THE WHOLE SPELL-FILE). IT'S
TOTAL STUPIDITY. And, NO. I'll _never_ believe that it makes the spell files readable. You read
it well, when you align the words and symbols right, just some simple examples:

if is_depends_enabled $SPELL giflib;
  optional_depends extra-gif-usage \
                   "--with-extra-gif" \
                   "--without-extra-gif" \
                   "for the extra GIF format usage"
fi

and bunch of C code:

if (x < 5)
{
  while (y != 0)
    z++;

  y += 1;
  w.x = y;
  window.z = z;
}

have you ever seen the code like this:

y += 1       ;
w.x = y      ;
window.z = z ;

? no? if you know why, then understand me right, please.

I'm just against the WASTING of spaces.

I don't think we need some strict rules about spell-writing or something. But, probably, a
recommendation/coding-style-guide would be good.

Well. Everything has the standards (also, well, not everyone follows them, but who cares?).
It's really hard to read the code without any identation or with wrong identation and
variable/function-naming issues. That's why there are coding style guides for Google internal
projects, WebKit. Not well-formed XHTML-code is ununderstandable! So be patient. Style guides
for C, C++, Python languages, and so on were a good idea. And, yes. W3C wasn't created by
dummies.

The last (i suppose) part, about my changes: I try to follow these standards.

1. double-space after if, else, etc. (yes, that came from the C. PEP8 still wants 4):

if [[ spell_ok $SPELL ]]; then
  if [[ ... ]]; then
    ...
  fi

  ...
elif
  ...
fi

2. then-usage on the _same_ line:

if [[ ... ]]; then
  ...
fi

3. reducing the spaces in DEPENDS:

optional_depends libpng \
                 "--with-png" \
                 "--without-png" \
                 "for PNG support" &&
not that ugly:

optional_depends  libpng             \
                  "--with-png"       \
                  "--without-png"    \
                  "for PNG support"  &&

when you change anything, no need to fix EVERY LINE in file (if some desc becomes longer, etc.)

4. one space > two spaces
two-spaces usage is only for identation from if, for, etc. So one is _enough_. Everything
extraneous is useless, imho.

5. removing useless quotes: as Jaka said -- everything static is ok, if dynamic -- like the
paths ($INSTALL_ROOT, $SOURCE_DIRECTORY) -- it must be quoted.

6. double-quotes instead of single ones: I just don't know really, but seems the spells are
written with most of _"_, not _'_, so I use the double ones.

7. and ofcourse.. missing `&&', quotes, bash-specific things (like "[[" instead of "["),
reducing the line-length to 80 chars (except for [PRE_]SUB_DEPENDS), usage $SPELL_DIRECTORY
over $SCRIPT_DIRECTORY, preference of `install' over `mkdir, cp', increase verbosity (with
-v flags or something) -- these are small but useful changes I always do, personally I prefer
warningless and ofc errorless system. Cause anyway progress is always good, and fixing our
awesome distro together makes much more sense instead of just yelling about the useless
things. Sorry, but I prefer motto of OpenBSD development: "shut up and hack". I contribute[d]
to many projects, including T2, Lunar (that's what that `d' was for :P), The Battle for Wesnoth,
and some others. SMGL is one of those few projects where good code, written by well-organised
community works well. So I just wanna stay in such community while making this distro a bit
better than it was yesterday. Thanks.

-- 
Dont wait to die to find paradise...
--
Cheerz,
Vlad "Enqlave" Glagolev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/sm-discuss/attachments/20080722/f3b96c51/attachment-0001.bin 


More information about the SM-Discuss mailing list