| Author |
Message |
|
| Mazen |
Posted: Thu Jul 20, 2006 4:55 pm |
|
|
|
User
Joined: 20 Jul 2006
Posts: 164
Location: London
|
| Maybe considered something less important, but atleast I like standards so that indentation between different editors becomes readable... Question is: Is there any documented "standard" for indentation in Erlang? if not, what about the other functional languages, do they have it? |
|
|
| Back to top |
|
| francesco |
Posted: Fri Jul 21, 2006 11:49 am |
|
|
|
User
Joined: 07 Jul 2006
Posts: 249
Location: London
|
The defacto standard is defined by how Emacs indents Erlang. The majority of erlang programmers use Emacs, so it makes sense to go that route.
On a curios side issue.. AxD301 guidelines state that you may use any editor you like, but indentation has to be emacs one. So the few survivors hack in vim/vi, load their code in emacs to indent it, and then check it in .
Francesco |
|
|
| Back to top |
|
| garazdawi |
Posted: Mon Jul 24, 2006 5:14 pm |
|
|
|
User
Joined: 10 Jul 2006
Posts: 20
|
The problem with the Emacs indentation as I see it is that it uses "halftabs" i.e. when you make the first indentation it uses four spaces and then the next indent it uses a proper tab.
function() ->
(space)(space)(space)(space)case ok of
(tab)error ->
(tab)(space)(space)(space)(space){error,error}
(space)(space)(space)(space)end.
I have never been able to understand why they don't just set the tab size to 4 spaces and use tabs everywhere instead of working with the "halftabs". The only reasons which I can think of is lazyness or that they want to force you to use Emacs. Anyone know the real reason? |
_________________ Erlang Training & Consulting |
|
| Back to top |
|
| oscarh |
Posted: Wed Jul 26, 2006 7:56 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 22
|
what emacs will use for tabs can be configured by the user, and thus not really a good standard instrument  |
|
|
| Back to top |
|
| michal |
Posted: Wed Jul 26, 2006 5:01 pm |
|
|
|
User
Joined: 20 Jul 2006
Posts: 44
Location: London
|
garazdawi wrote: I have never been able to understand why they don't just set the tab size to 4 spaces and use tabs everywhere instead of working with the "halftabs". The only reasons which I can think of is lazyness or that they want to force you to use Emacs. Anyone know the real reason?
I don't know the reason, but I would rather stay with the tab 8 spaces wide. Otherwise reading through OTP code is much harder...
It is nice to work in the editor that automatically indents the code every time when you press the tab key, but I think it should use only spaces not halftabs.
Does vim have any automatic indentation policy? |
|
|
| Back to top |
|
| oscarh |
Posted: Thu Jul 27, 2006 8:54 am |
|
|
|
User
Joined: 20 Jul 2006
Posts: 22
|
michal wrote: Does vim have any automatic indentation policy?
In vim you set either the option expandtabs or noexpandtabs. With expandtabs, spaces will be inserted instead, using as many as indicated by the variable shiftwidth. If noexpandtabs is set, a tab key will result in a tab character. However, if you do indentation, it is up to the plugin (or user) to make sure that no "halftabs" are inserted, since the indentation level is given in ammount of spaces (calculated from shiftwidth usually). |
|
|
| Back to top |
|
| martin |
Posted: Sun Aug 06, 2006 11:53 am |
|
|
|
User
Joined: 06 Aug 2006
Posts: 11
|
michal wrote: It is nice to work in the editor that automatically indents the code every time when you press the tab key, but I think it should use only spaces not halftabs.
Well you can always insert (setq-default indent-tabs-mode nil) in your .emacs file  |
|
|
| Back to top |
|
|
|