Hi all In the file abort.pl in Koha 3 I see the follow cryptic comment: # Please use 8-character tabs for this file (indents are every 4 characters) Does this mean that tabs should not be used for indentation, since a tab would indent 8 character positions in the source? Does this imply that we should be using FOUR SPACES for each indent level? If the answer to the latter is yes, I must register my protest. Might I suggest that we adopt a an indentation standard that makes use of the TAB character, and that the tab stop be set to 4 character positions? As it stands, much of the Koha source code is difficult to read and suffers from a variety of inconsistent indentation styles. Comments from developers most welcome. cheers rickw -- ________________________________________________________________ Rick Welykochy || Praxis Services || Internet Driving Instructor When the power of love overcomes the love of power, the world will know peace. -- Jimi Hendrix
On Wed, Nov 12, 2008 at 8:15 PM, Rick Welykochy <rick@praxis.com.au> wrote:
Hi all
In the file abort.pl in Koha 3 I see the follow cryptic comment:
# Please use 8-character tabs for this file (indents are every 4 characters)
Does this mean that tabs should not be used for indentation, since a tab would indent 8 character positions in the source?
Does this imply that we should be using FOUR SPACES for each indent level?
If the answer to the latter is yes, I must register my protest.
Hi Rick - I recently tried to gather some of the more common preferences for formatting perl code in the Koha community and put together this perltidyrc file: http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blob;f=xt/perltidyrc It might be a good starting point for discussing formatting preferences for Koha code. I try to use it for code I contribute, though I most certainly have forgotten sometimes. I'm not sure about the origin or the accuracy of the particular comment you pointed out. -Andy
On 2008/11/13, at 3:35 PM, Andrew Moore wrote:
On Wed, Nov 12, 2008 at 8:15 PM, Rick Welykochy <rick@praxis.com.au> wrote:
Hi all
In the file abort.pl in Koha 3 I see the follow cryptic comment:
# Please use 8-character tabs for this file (indents are every 4 characters)
I don't know the history of this comment, but i wouldnt wotry too much about it its old and not very well enforced (at least) I think we should all agree on a standardised .perltidyrc format, and i vote for Andy's ;) Ive been using Andy's since he first posted it on the list, and its a nice format for me Thanks again Andy!
Hi Rick -
I recently tried to gather some of the more common preferences for formatting perl code in the Koha community and put together this perltidyrc file:
http://git.koha.org/cgi-bin/gitweb.cgi?p=Koha;a=blob;f=xt/perltidyrc
-Andy
Mason James wrote:
I don't know the history of this comment, but i wouldnt wotry too much about it its old and not very well enforced (at least)
I think we should all agree on a standardised .perltidyrc format, and i vote for Andy's ;) Ive been using Andy's since he first posted it on the list, and its a nice format for me
May I assume then that the answer to tab stops is: (*) yes, use them to indent (*) assume the tab stop is every four characters Are we agreed? As far as a standardised .perltidyrc, my only comment is "please explain!" cheers rickw -- ________________________________________________________________ Rick Welykochy || Praxis Services || Internet Driving Instructor When the power of love overcomes the love of power, the world will know peace. -- Jimi Hendrix
On 2008/11/13, at 7:45 PM, Rick Welykochy wrote:
Mason James wrote:
I don't know the history of this comment, but i wouldnt wotry too much about it its old and not very well enforced (at least) I think we should all agree on a standardised .perltidyrc format, and i vote for Andy's ;) Ive been using Andy's since he first posted it on the list, and its a nice format for me
May I assume then that the answer to tab stops is:
(*) yes, use them to indent
hmm , thats close to a holy-war topic Rick ;) i personally would choose tabs too but i think we might have to allow either tabs or spaces from developers - (thats perltidys behavior too afaik) the important thing is a consistent indent length of 4, i think.
(*) assume the tab stop is every four characters
yeah, i think thats 97% standard in koha now
Are we agreed?
no, tabs and spaces i think any other strong opinions people?
As far as a standardised .perltidyrc, my only comment is "please explain!"
hmm, only after you google 'explain perltidyrc' ;) Mason.
Mason James wrote:
but i think we might have to allow either tabs or spaces from developers - (thats perltidys behavior too afaik)
Why would anyone indent with spaces?
the important thing is a consistent indent length of 4, i think.
Hooray for that!
As far as a standardised .perltidyrc, my only comment is "please explain!"
hmm, only after you google 'explain perltidyrc' ;)
So, are we perltidying the source code in Koha? If not, any plans to? And what about the templates? They are often mind-bending to edit, and I've seen no tools to assist in comprehending their structure. IMHO, indentation in hand-coded HTML is just as important as that in perl and other languages. cheers rickw -- _________________________________ Rick Welykochy || Praxis Services Tis the dream of each programmer before his life is done, To write three lines of APL and make the damn thing run.
Rick Welykochy a écrit :
Mason James wrote:
but i think we might have to allow either tabs or spaces from developers - (thats perltidys behavior too afaik)
Why would anyone indent with spaces?
we spoke of that a loonnnggg time ago. I don't remember the details, but i remember that I've changed my way of indenting from tab to spaces. And since then all commits are done with spaces, I think the tab ones are oldies that have never be fixed.
the important thing is a consistent indent length of 4, i think.
Hooray for that!
yep.
And what about the templates? They are often mind-bending to edit, and I've seen no tools to assist in comprehending their structure.
agreed... -- Paul POULAIN http://www.biblibre.com Expert en Logiciels Libres pour l'info-doc NOUVEAU TELEPHONE : 04 91 81 35 08
And what about the templates? They are often mind-bending to edit, and I've seen no tools to assist in comprehending their structure.
agreed...
The Perl scripts are mind-bending to me. I suspect it's whatever you're most used to (I've spent WAY too much time in template world by now). But I'd love to hear any suggestions on how to make things easier for others. -- Owen -- Web Developer Athens County Public Libraries http://www.myacpl.org
On Thu, Nov 13, 2008 at 7:03 AM, Owen Leonard <oleonard@myacpl.org> wrote:
And what about the templates? They are often mind-bending to edit, and I've seen no tools to assist in comprehending their structure.
agreed...
The Perl scripts are mind-bending to me. I suspect it's whatever you're most used to (I've spent WAY too much time in template world by now). But I'd love to hear any suggestions on how to make things easier for others.
-- Owen
-- Web Developer Athens County Public Libraries http://www.myacpl.org _______________________________________________ Koha-devel mailing list Koha-devel@lists.koha.org http://lists.koha.org/mailman/listinfo/koha-devel
I think the main problem with that is HTML::Template::Pro's extremely odd syntax and very limited capabilities (which, despite their professed reasons, do _not_ make the templates parsable by a XML/HTML parser or validatable with a DTD except for simple cases). That is a whole other tangent, though. As far as tabs/spaces go, the de facto standard that I know of is 4 spaces per indent level. This seems to be reflected in the code, and I think we should put it on http://wiki.koha.org/doku.php?id=en:development:codingguidelines . -- Jesse Weaver Software Developer, LibLime
On 2008/11/14, at 2:50 AM, Paul POULAIN wrote:
Rick Welykochy a écrit :
Mason James wrote:
but i think we might have to allow either tabs or spaces from developers - (thats perltidys behavior too afaik)
Why would anyone indent with spaces?
check this link for hearty examples of 'tabs versus spaces' discussion, enjoy ;) http://www.perlmonks.org/?node_id=576936 for me, the above discussion eventually has a obvious conclusion, which is... tabs have the possibility to be displayed in a whole bunch of different ways depending on what os/shell/editor/termtype/xterm/whatever combination you are using and spaces dont,.. i think spaces continue to be the best 'lowest-common-denominator' choice for a big open-source project like koha,
we spoke of that a loonnnggg time ago. I don't remember the details, but i remember that I've changed my way of indenting from tab to spaces. And since then all commits are done with spaces, I think the tab ones are oldies that have never be fixed.
the important thing is a consistent indent length of 4, i think.
Hooray for that!
yep.
And what about the templates? They are often mind-bending to edit, and I've seen no tools to assist in comprehending their structure.
agreed...
yep i had a look about 2.5 years ago at 'htmltidy' to help format the templates, but i hit a bit of problem the problem was that htmltidy doesnt understand the <!-- TMPL_*** --> tags, so it cant properly format the file the best it can do is ignore the tags, and not give a parse-error :/ so, it still has it uses for tiding a messy template file, but the indentation needs to be done manually after the parse but still, better than nothing... there was a work-in-progress mod for HTML::Template support in htmltidy, but i cant spot it in the current cvs tree ( i may have missed it ) http://tidy.cvs.sourceforge.net/viewvc/tidy/tidy/ has there been any better html-type pretty-printer projects since, people??? or is htmltidy still the closest thing we have for this task it would be a very big win if we could find a tool to help standardise the templatefiles format, and tidy up the messy existing files too its been ages since i last looked at htmltidy, so its worth another look, even just to check on the (non)progress of the HTMPL::Template handling code FYI: heres the link http://tidy.sourceforge.net/ Mason.
Mason James wrote:
check this link for hearty examples of 'tabs versus spaces' discussion, enjoy ;)
http://www.perlmonks.org/?node_id=576936
for me, the above discussion eventually has a obvious conclusion, which is...
tabs have the possibility to be displayed in a whole bunch of different ways depending on what os/shell/editor/termtype/xterm/whatever combination you are using
and spaces dont,..
i think spaces continue to be the best 'lowest-common-denominator' choice for a big open-source project like koha,
I agree with the above article. TABs are metadata, not display data. They give the programmer and reader a reliable indication of the structure of a program through consistent indentation. It is quite trivial for any viewer to set TAB STOP = 4 (or whatever is agreed upon) and get a consistent presentation. But presentation != metadata.
FYI: heres the link http://tidy.sourceforge.net/
There is only one caveat with tidy programs. One little bug can cause loss or change the semantics of what is being tidied. Silently. cheers rickw -- _________________________________ Rick Welykochy || Praxis Services Tis the dream of each programmer before his life is done, To write three lines of APL and make the damn thing run.
Hi,
-----Message d'origine----- De : koha-devel-bounces@lists.koha.org [mailto:koha-devel-bounces@lists.koha.org] De la part de Rick Welykochy Envoyé : 13 novembre 2008 20:08 Objet : Re: [Koha-devel] Tab stops in source code
TABs are metadata, not display data. They give the programmer and reader a reliable indication of the structure of a program through consistent indentation.
This is debatable. The structure of a program is the code. The way this code is displayed on a screen is the presentation. A program don't need any tabs or indentation to run, because tabs do not control anything. The code could be all on one line and run nevertheless because its structure is correct. Visual structure == presentation and tabs or spaces are part of that structure, not part of the structure of the program itself. And for what it's worth, I prefer tab over spaces in my own code. Sébastien Nadeau Bibliothèque de l'Université Laval
On Thu, Nov 13, 2008 at 12:45 AM, Rick Welykochy <rick@praxis.com.au> wrote:
May I assume then that the answer to tab stops is:
(*) yes, use them to indent
That doesn't seem to be historically the most preferred method. Here are some statistics (that are probably lying in some way): number of perl files in C4 with a line starting with at least one space: acm@arwen:~/koha/dev/C4$ ack --perl -cl "^\ +" . | wc -l 220 number of perl files in C4 with a line starting with at least one tab: acm@arwen:~/koha/dev/C4$ ack --perl -cl "^\t+" . | wc -l 96 Total number of lines in perl files in C4 that start with at least one space: acm@arwen:~/koha/dev/C4$ ack --perl -cl "^\ +" . | cut -d: -f2 | awk '{ total += $1 } END { print total }' 28890 total number of lines in perl files in C4 that start with at least one tab: acm@arwen:~/koha/dev/C4$ ack --perl -cl "^\t+" . | cut -d: -f2 | awk '{ total += $1 } END { print total }' 6475 I guess the POD blocks are probably throwing this off somewhat. I'm not really sure how badly, though. That's hard to count. ;) I think there are at least one or two contributors who use tab characters to indent their stuff. Most recent patches I've seen seem to use spaces, from what I can recall. -Andy
On Thu, Nov 13, 2008 at 12:45 AM, Rick Welykochy <rick@praxis.com.au> wrote:
As far as a standardised .perltidyrc, my only comment is "please explain!"
Hi again, Rick - perltidy is a tool that attempts to format perl code in a consistent way. That .perltidyrc file sets most things to the default, but changes a few things to be consistent with what seemed like was common agreement at some point. I actually stole most of the settings from a few emails that were traded on some Koha list several years before I arrived on the scene. I stuck it in git so that we could all get to it. I've been using it to format new blocks of code that I contribute. I have my editor set to take a portion of a file and replace it with the portion that has been formatted with perltidy. I've tried to remember to do that on most new code I submit and on pieces that I change. No one seems to be complaining about the format of my code too loudly, yet, so I guess it's mostly acceptable to the community. I have noticed that proposals that seek to reformat files in bulk have not been received too well. I encourage you to take a look at perltidy. I think it makes perl code a little bit more readable. -Andy
2008/11/12 Rick Welykochy <rick@praxis.com.au>:
# Please use 8-character tabs for this file (indents are every 4 characters)
Does this mean that tabs should not be used for indentation, since a tab would indent 8 character positions in the source?
Does this imply that we should be using FOUR SPACES for each indent level?
If the answer to the latter is yes, I must register my protest.
Might I suggest that we adopt a an indentation standard that makes use of the TAB character, and that the tab stop be set to 4 character positions?
As it stands, much of the Koha source code is difficult to read and suffers from a variety of inconsistent indentation styles.
I remember the same discussion from the time when I was active in Koha, and I happen to hold the opposite position (i.e., I agree that we should be using four spaces to indent, tabs when thee should be eight spaces). As far as I can see, whether you agree or oppose depends on how you read source and what program you use to edit files. For people who reads source in xterms and edit with vi, indenting with tabs is unnatural and makes the source extremely hard to read; for people who use graphical editors, they would prefer tabs. Since I am no longer active in Koha, my opinions don't matter much, but I just wish to point out that normally Perl code (at least those that come with Perl itself) is indented with 4 spaces (so that they appear correctly when browsed with, for example, less), not with tabs. -- cheers, -ambrose The 'net used to be run by smart people; now many sites are run by idiots. So SAD... (Sites that do spam filtering on mails sent to the abuse contact need to be cut off the net...)
participants (8)
-
Ambrose Li -
Andrew Moore -
Jesse Weaver -
Mason James -
Owen Leonard -
Paul POULAIN -
Rick Welykochy -
Sébastien Nadeau