Re: [Vala] Coding standard: indentation?



2009/2/9 Michel Salim <michel sylvan gmail com>:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

All the Vala code I've seen so far use 8-space indentation, with Tabs
not converted to spaces. Is this documented somewhere as being the
preferred style?

I'm packaging Vala Toys for gedit right now, and it uses this for its
project generator, and when editing Vala source, any attempt to change
the indentation gets reset to 8-space/TAB when the file is saved.
Granted, this is probably a bug (that I'll report), but a clarification
would be useful.

Googling for Vala indentation yields this interesting discussion at
gupnp, which uses Vala:

http://lists.o-hand.com/gupnp/0421.html

It seems to suggest that Vala code in the wild uses 4-space indentation,
which probably ends up more readable (less overflowing) than 8-space on
most screens. I personally prefer 2-space indentation when dealing with
languages with compact syntax, stretching to 4 for C-like languages.

The tutorial code I've seen so far seems to use 8-space, and some of
them are over the 80-char width limit, making it rather awkward to edit
on the console.

Generally, Vala style is based on gnome's, with of course some
allowances for syntax.  This is where the standards for things like
spaces before brackets come from.  Vala's own code is the main
reference source - that's what most of the samples are based on - and
uses always unexpanded tabs, so their size is somewhat optional,
although 8 space would probably look very over the top on a language
with clean syntax.

The tutorial on l.g.o, and most of the samples there, are largely
written to look like the Vala source, but are actually indented with
spaces as browsers tend to default to 8 space tabs.

Incidentally, would it be a good idea to move the tutorial code to a
module under version control? That way they can be matched to different
Vala releases, and developers can track Vala's evolution by tracking
changes in the sample programs.

Would be good, but also a bit of a management problem.  Not only would
they have to be kept synchronized, it would also make it trickier to
let people add and maintain...  Possibly a separate repo could be used
to keep the history around in an easier to track way than wiki, but
someone would still have to put quite a lot of time into it.

-- 
Phil Housley



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]