Post Reply 
compiled or not?
12-17-2015, 03:39 PM
Post: #9
RE: compiled or not?
(12-15-2015 07:02 AM)hpfx Wrote:  While you are there, can we get rid of that forward declaration of functions ?
You could collect symbol at compilation and avoid requesting user to list functions at begining of program.
It makes years new language does not require it anymore.
I had to explain that to my son, it's not obvious for youngers, does not add anything and make programs more complex.

When I was first learning programming, one thing that made sense to me was the idea that you had to define a new word before you could use it. Instead of using forward declarations, the prof had us just define the function first:

Code:
dbl(x)
BEGIN
 RETURN 2*x;
END;

EXPORT aaa(x)
BEGIN
 RETURN dbl(x);
END;

I think the only time you really NEED forward declarations is when you have two functions that are mutually recursive.

Code:
// forward declaration required
m(n);

f(n)
BEGIN
 RETURN IFTE(n==0, 1, n-m(f(n-1)) );
END;

m(n)
BEGIN
 RETURN IFTE(n==0, 0, n-f(m(n-1)) );
END;

EXPORT HFM(n)
BEGIN
 PRINT;
 PRINT(f(n));
 PRINT(m(n));
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
compiled or not? - ji3m - 12-15-2015, 12:41 AM
RE: compiled or not? - luisphysics - 12-15-2015, 02:26 AM
RE: compiled or not? - eried - 12-15-2015, 04:03 AM
RE: compiled or not? - hpfx - 12-15-2015, 07:02 AM
RE: compiled or not? - Wes Loewer - 12-17-2015 03:39 PM
RE: compiled or not? - hpfx - 12-17-2015, 09:58 PM
RE: compiled or not? - Wes Loewer - 12-18-2015, 01:12 PM
RE: compiled or not? - hpfx - 12-18-2015, 05:15 PM
RE: compiled or not? - ji3m - 12-15-2015, 01:50 PM
RE: compiled or not? - ji3m - 12-16-2015, 01:04 PM
RE: compiled or not? - ji3m - 12-18-2015, 07:27 PM
RE: compiled or not? - eried - 12-19-2015, 12:00 AM
RE: compiled or not? - ji3m - 12-19-2015, 05:08 AM



User(s) browsing this thread: 1 Guest(s)