LWN.net Logo

What Red Hat and Firestar agreed to

What Red Hat and Firestar agreed to

Posted Jul 15, 2008 18:55 UTC (Tue) by vmole (guest, #111)
Parent article: What Red Hat and Firestar agreed to

The settlement itself reads somewhat like a Pascal program; one must start toward the bottom and read it in reverse.

+1 for QOTW.


(Log in to post comments)

What Red Hat and Firestar agreed to

Posted Jul 15, 2008 19:19 UTC (Tue) by darwish07 (subscriber, #49520) [Link]

I did not work on Pascal before. 

Does Mr. Corbet means something like below C program where lots of internal function code
exist and the main() is thrown at the end (where you have to scroll down till main() code to
understand the big picture) ? 

Ex:

func1() {
   // lots of code
}

func2() {
   // lots of code
} 
.
.
.

main() {
   func2();
   if () func3(0;
   ...
}

What Red Hat and Firestar agreed to

Posted Jul 15, 2008 19:30 UTC (Tue) by vmole (guest, #111) [Link]

Yeah, that's it exactly. Pascal didn't allow forward references/decarations/definitions, so you were basically forced into this style of coding.

Looks like your Pascal knowleadge is lacking

Posted Jul 15, 2008 20:09 UTC (Tue) by khim (subscriber, #9252) [Link]

Pascal DOES have forward definitions. Always had. There are exactly ONE exception: main program goes to the end. All other procedures and functions can be moved around as you wish, but main program goes to the end - always.

Looks like your Pascal knowleadge is lacking

Posted Jul 15, 2008 23:10 UTC (Tue) by vmole (guest, #111) [Link]

I freely admit my Pascal knowledge is long forgotten, but in my defense, I offer this quote from Brian Kernighan's Why Pascal is Not My Favorite Language: "Since the original Pascal was implemented with a one-pass compiler, the language believes strongly in declaration before use. In particular, procedures and functions must be declared (body and all) before they are used." I should have remembered also his note that there was a "forward" declaration, with some restrictions.

Looks like your Pascal knowledge is lacking

Posted Jul 18, 2008 0:48 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

I think the difference between C and Pascal here isn't in the language definition; it's in the culture. C's culture is get-the-job-done and Pascal's is one of mathematical elegance.

In both languages, you have to declare a subroutine before you can call it. If you don't want to fully define it, you at least need a prototype. (It's the reason I always write C upside down -- I hate writing anything twice).

In Pascal, the custom is that if subroutine bar supports foo, you code bar inside foo. You can do that in C too, but it's nearly unheard of. If you do that, in either language, you must define bar before the procedural code of foo; to do otherwise would be like declaring variables at the bottom of a subroutine.

Pascal does have a "program" concept that C doesn't have (a C program is just a collection of zero or more peer subroutines; only the linker knows how to turn them into a program), which means at least one line of main code does have to go at the bottom of the main file of a program, even if you otherwise eschew the nested subroutine convention.

Looks like your Pascal knowledge is lacking

Posted Jul 18, 2008 11:20 UTC (Fri) by nix (subscriber, #2304) [Link]

Actually nested functions aren't valid in C. They're a GCC extension, and 
while I might wish they were in the Standard (give us closures, too, 
please!) they're not.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds