|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Fri Sep 01, 2017 2:28 am Post subject: Debugger improvements |
|
|
SDBG has nice feature showing variable value in tiny popup screen when you point on variable with the mouse. Would be great to add the same feature when you point on ENDIFs and ENDDOs. Something like here (on this static image shown all popups at the same time but of course only one will be seen in reality)
That will help us not to be lost in the spaghetti codes |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8017 Location: Salford, UK
|
Posted: Fri Sep 01, 2017 7:55 am Post subject: |
|
|
I would often write this as !comment in the code.
Also, don't forget that constructs can be named in Fortran 90. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Fri Sep 01, 2017 9:40 am Post subject: |
|
|
I also do comment enddos and endifs. But I started doing this just recently after hundreds of thousands of lines of codes when the mess became unbearable . Because nobody teaches good coding practices so my $10 bet is that most people don't do that. And naming is way too rarely used, and is known and much less used only by very advanced coders. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Fri Sep 01, 2017 3:35 pm Post subject: |
|
|
Dan,
When I was programming in Algol-60, back in the 1960s, the use of indenting was essential, and I spent many hours drawing links between the start of a loop and its end using different coloured pens. Can I help by sending you a set, along with a long ruler, down to the South Pole? Can you still get your source codes printed on music-ruled fan-fold paper on a line printer?
At least with traditional Fortran DO loops one automatically gets a connection between the DO statement and the final CONTINUE statement through the statement number of the latter, which in fixed-format source codes is an 'outdent'. It slowly dawned on me that what I had seen as a primitive defect was actually a helpful construct.
But sadly, the past is a foreign country where they do things differently (or so said H. E. Bates in 'The Go Between'). Don't believe people who say the past (or indeed, the primitive) was always worse!
Eddie |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Fri Sep 01, 2017 11:29 pm Post subject: |
|
|
Eddie, oh yeah, the indentation is simply a must, I completely forgotten mentioning it, because it is so natural that you don't even notice it. You are dead without it in large codes. As to coloring - here is where I don't have opinion. I tried to convince my editor developer 20 years ago to implement coloring because almost all do that but he refused... I think Plato also has it but I use batch files to compile instead. As a result I have no clue if it actually helps or distracts. What is your opinion?
Last edited by DanRRight on Sat Sep 02, 2017 9:40 am; edited 2 times in total |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2585 Location: Sydney
|
Posted: Sat Sep 02, 2017 12:49 am Post subject: |
|
|
Hi Dan,
Plato does have colouring, although the colours don't contrast a lot. I'm sure I could change the colour palette.
To keep track of nested or long DO loops I have always suggested using the DO variable as an alternate DO label, but few have given that support. The alternative I often use is END DO ! DO_variable, eg
Code: | !
do j = 1,ncb
c(:,j) = 0
do k = 1,nca
c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
end do ! k
end do ! j
! |
It is good to see that we are thinking similarly. It is just a shame more on the Fortran committee don't have the same experience. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Sat Sep 02, 2017 1:56 pm Post subject: |
|
|
John,
It is intriguing that the content of your do loop is one step further indented than the start and finish. Wouldn't:
Code: | !
do j = 1,ncb
c(:,j) = 0
do k = 1,nca
c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
end do ! k
end do ! j
! |
be more logical?
Eddie |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1896
|
Posted: Sat Sep 02, 2017 6:05 pm Post subject: Re: |
|
|
LitusSaxonicum wrote: |
It is intriguing that the content of your do loop is one step further indented than the start and finish. |
The Fortran style guide at http://www.fortran90.org/src/best-practices.html#indentation would support John's style. That guide uses four spaces for indentation. Others may use fewer or more spaces, or tabs. Having the DO and the matching END DO indented less than the statements in the body of the DO construct (and likewise for IF...ENDIF, etc.) makes it clear where the loop starts and where it ends, and whether a statement is in the loop or not.
I usually don't bother too much about style when editing source code. After I am done, I can use a utility to reformat ("pretty print") the whole code in a standard way. |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Sat Sep 02, 2017 11:19 pm Post subject: |
|
|
Mecej4,
It doesn't work for me. I prefer no indent at all, blank lines, CONTINUE and statement numbers. It's the 'the way nature intended' as I see it (quote misused from the Silverfrost top page) ;-).
If I had to use indents, then I'm sure that I would find having the content indented differently obfuscated the connection between the beginning, content, and end.
But then I don't indent loops, not since ALGOL days, and they ended, abruptly, in 1970 ! My recollection was that they were indented rather like John's layout, but the interior code began with "BEGIN" and ended with "END" which made it a sort of logical block.
Eddie |
|
Back to top |
|
|
LitusSaxonicum
Joined: 23 Aug 2005 Posts: 2393 Location: Yateley, Hants, UK
|
Posted: Wed Sep 13, 2017 3:16 pm Post subject: |
|
|
I wouldn't indent, but then I'd have statement numbers. They are an 'outdent', akin to a tab on the left. Then it's obvious where the loop ends.
The need for wider layouts is due to longer names and indents. Neither are essential.
Just saying.
Eddie |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Wed Sep 13, 2017 6:43 pm Post subject: |
|
|
Code: | ! JohnC's 'starter for 10' version (10)
some code here
some more code here
do j = 1,ncb
c(:,j) = 0
do k = 1,nca
c(1:nra,j) = c(1:nra,j) + a(1:nra,k) * b(k,j)
end do ! k
end do ! j
almost last code here
last code here |
2 spaces is also my style. I can not afford 4 with free style and 132 places. The editor has to keep open two panes with two files simultaneously. Occupies almost all 3840 pixels of screen width
For better visible separation of subroutines in the files each containing ~20000 lines i use huge banners made using this site below. Here is one for Main program
Code: | !http://patorjk.com/software/taag/#p=display&h=2&v=0&f=Doh&t=Main%20GUI
!MMMMMMMM MMMMMMMM iiii
!M:::::::M M:::::::M i::::i
!M::::::::M M::::::::M iiii
!M:::::::::M M:::::::::M
!M::::::::::M M::::::::::M aaaaaaaaaaaaa iiiiiii nnnn nnnnnnnn
!M:::::::::::M M:::::::::::M a::::::::::::a i:::::i n:::nn::::::::nn
!M:::::::M::::M M::::M:::::::M aaaaaaaaa:::::a i::::i n::::::::::::::nn
!M::::::M M::::M M::::M M::::::M a::::a i::::i nn:::::::::::::::n
!M::::::M M::::M::::M M::::::M aaaaaaa:::::a i::::i n:::::nnnn:::::n
!M::::::M M:::::::M M::::::M aa::::::::::::a i::::i n::::n n::::n
!M::::::M M:::::M M::::::M a::::aaaa::::::a i::::i n::::n n::::n
!M::::::M MMMMM M::::::Ma::::a a:::::a i::::i n::::n n::::n
!M::::::M M::::::Ma::::a a:::::a i::::::i n::::n n::::n
!M::::::M M::::::Ma:::::aaaa::::::a i::::::i n::::n n::::n
!M::::::M M::::::M a::::::::::aa:::ai::::::i n::::n n::::n
!MMMMMMMM MMMMMMMM aaaaaaaaaa aaaaiiiiiiii nnnnnn nnnnnn |
Last edited by DanRRight on Wed Sep 13, 2017 7:21 pm; edited 1 time in total |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Wed Sep 13, 2017 7:06 pm Post subject: |
|
|
Since all codes on Earth are full of devilry, this separator is also recommended for Main GUI
Code: | | . . _ _
))) |.===. . .:::. '\\-//` -*~*- \-^-/ |||
(o o) {}o o{} :(o o): . (o o) (o o) (o o) (o o)
ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo---ooO--(_)--Ooo-ooO--(_)--Ooo-ooO--(_)--Ooo- |
or this
Code: | \\\ /// wW Ww\\\ /// \/ wWw wWw wW Ww
((O) (O)) /) (O)(O)((O)(O)) (OO) (O) (O) (O)(O)
| \ / | (o)(O)(..) | \ || ,'.--.) / ) ( \ (..)
||\\//|| //\\ || ||\\|| / /|_|_\ / / \ \ ||
|| \/ || |(__)|_||_ || \ | | \_.--. | \____/ | _||_
|| || /,-. (_/\_) || || '. \) \'. `--' .`(_/\_)
(_/ \_)-' '' (_/ \_) `-.(_.' `-..-' |
and this called "Ghost"
Code: | _ .-') ('-. .-') _
( '.( OO )_ ( OO ).-. ( OO ) )
,--. ,--.) / . --. / ,-.-') ,--./ ,--,' ,----. ,--. ,--. ,-.-')
| `.' | | \-. \ | |OO)| \ | |\ ' .-./-')| | | | | |OO)
| |.-'-' | | | | \| \| | ) | |_( O- ) | | .-') | | \
| |'.'| | \| |_.' | | |(_/| . |/ | | .--, \ |_|( OO ) | |(_/
| | | | | .-. |,| |_.'| |\ | (| | '. (_/ | | `-' /,| |_.'
| | | | | | | (_| | | | \ | | '--' (' '-'(_.-'(_| |
`--' `--' `--' `--' `--' `--' `--' `------' `-----' `--' |
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Wed Sep 13, 2017 7:33 pm Post subject: |
|
|
Other examples
Code: | ! ___ ___ _______ __ ___ ___
! |" \/" | /" \ /""\ |" \/" |
! \ \ / |: | / \ \ \ /
! \\ \/ -- |_____/ ) /' /\ \ \\ \/
! /\. \ -- // / // __' \ / /
! / \ \ |: __ \ / / \\ \ / /
! |___/\___| |__| \___)(___/ \___)|___/
!
! ________ _______ _______ ______ ___________ _______ __
! /" )| __ "\ /" "| /" _ "\(" _ ")/" \ /""\
! (: \___/ (. |__) :)(: ______)(: ( \___))__/ \\__/|: | / \
! \___ \ |: ____/ \/ | \/ \ \\_ / |_____/ ) /' /\ \
! __/ \\ (| / // ___)_ // \ _ |. | // / // __' \
! /" \ :)/|__/ \ (: "|(: _) \ \: | |: __ \ / / \\ \
! (_______/(_______) \_______) \_______) \__| |__| \___)(___/ \___)
! |
Code: | !
! 8888888b. 888 8888888b. 8888888 .d8888b.
! 888 Y88b 888 888 Y88b 888 d88P Y88b
! 888 888 888 888 888 888 888 888
! 888 d88P .d88b. .d8888b 888888 888 d88P 888 888
! 8888888P" d88""88b 88K 888 8888888P" 888 888
! 888 888 888 "Y8888b. 888 888888 888 888 888 888
! 888 Y88..88P X88 Y88b. 888 888 Y88b d88P
! 888 "Y88P" 88888P' "Y888 888 8888888 "Y8888P"
! |
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Thu Sep 14, 2017 4:12 am Post subject: |
|
|
ASCII sources are boring. With such beautifications you will start a bit loving them.
When compilers will accept normal human oriented editors, like WORD and PowerPoint for Windows with their DOC, DOCX etc files? There we can add graphics and tables for documenting, clarification and just for beautifications. Silverfrost/Salford, how about you, remember your glorious days of being first to offer something new!
But let's return to our poor sheeps, I still like to see very very much that SDBG to show the matching if/else/endif and do/enddo. Just right now I again was stopped with some my own bugs and again losing hell of time, swearing, hell angry at myself, trying to add indentations and separators, to finally find the ends of numerous if/endifs in my own code written 30 years ago as a spaghetti code. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2585 Location: Sydney
|
Posted: Fri Sep 15, 2017 1:38 am Post subject: |
|
|
Dan,
You have to eliminate the bugs !!
Bugs are "coding errors" not "devilry"
Throw out the Ouija board and give /IM a go.
You then have to develop a table of all variables being used. It provides a way of looking at the code in a slightly different way and could help identify where some coding errors may be.
John |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|