Leaks
Post Reply
Quote
Re: Leaks
Posted by Monqui on Sat Feb 21st at 7:36pm 2004


? quote:
I've just come across function pointers this semester, and it seems like they could come in useful sometime. Recursion is something that everyone says is useful (or essential, and incredibly neat and tidy compared to the alternatives in many situations), but the only time I've used it is in trees, and I can't thik of many more practical uses.


Try working in a functional language (like Scheme, LISP, Hascal, etc.). Loops don't exist- the only way to do things is via recursion.

Those languages are 1337 because you get these obscenely long looking things that do incredibly dull things... For example- this line:

(define member-slst? (lambda (s slst) (if (null? slst) #f (or (if (symbol? (car slst)) (equal? s (car slst)) (member-slst? s (car slst))) (member-slst? s (cdr slst))))))

Simply reads through a list of symbols and returns t or f, depenging on whether or not s is a member of the slist. Without recursion, I think I might have shot myself in the face. [addsig]




Quote
Re: Leaks
Posted by Edge Damodred on Sat Feb 21st at 8:14pm 2004


There's a reason progress happens Monqui... [addsig]



Quote
Re: Leaks
Posted by Crono on Sat Feb 21st at 8:40pm 2004


? quote:
Function pointers can be used very well in C++ (as pointers to member functions) to provide one interface to many different methods ,ergo Run Time Polymorphism. In C, I am yet to see a good use though.

BTW: anyone who wants to feel the power of recursion, attempt the Towers of Hanoi problem without recursion and then debate



. . . why aren't you using Dynamic Binding??

and Edge, how would the definitions change? I mean the only thing I could think of would be to make a struct node and make it to where the programmer could change the struct node to hold whatever datatypes he wanted, then because you used operator overloading, you overloaded many many many many different arguments for the same operators (and yes it would work nicely lol) they could theoretically use your stuff without you using templates. . . but you shouldn't really let people use your code like that, especially because they'd have to compile it and such . . . anyway.

Why keep a void pointer?? that would only be useful in an inhertance heirarcy, and even then you just keep a pointer of the Abstract Base. . . (Meaning you shouldn't really use a pointer of type void because you still don't know what it's pointing to, especially if you assign it in a loop or when using recursion.)

Yeah, there is a crap load of messy code out there for games .. . pick up a Direct3D game programming book sometime (litterally just pick it up, don't buy it or anything) you'll probably be disgusted at the code.

Anyway, I know most wont agree on my programming methodalagy. But anyway, Nice to see some *cough* coders out there . . . keep learning guys lol. (by the way, monqui, why would you (sort of) bitch about a language you use? I mean if it's difficult to use and there isn't much use in the output . . . why are you using it? Probably for a class, I hope, but then you might want to question the instructor as to why they chose the language (in most classes at PSU the professor chooses the language it's in . . . oh man, I hope I get a dude who wants Java in the compiler courses lol.) [addsig]




Quote
Re: Leaks
Posted by Monqui on Sat Feb 21st at 10:44pm 2004


I'm not bitching, I really actually enjoy working in Scheme.

Oh, and these languages are still in use- in fack Jak II for the PS2 has a very large amount of code written in GOAL.

It's fast, simple to learn, and really powerful once you get the hang of it. Who needs variables, anyways? [addsig]




Quote
Re: Leaks
Posted by fraggard on Sun Feb 22nd at 3:15am 2004


? posted by Crono
. . . why aren't you using Dynamic Binding??

I know virtual functions are an easier way, but that's not the only way to go. Some special cases, function pointers are much easier.





Quote
Re: Leaks
Posted by Edge Damodred on Sun Feb 22nd at 3:41am 2004


I've worked with D3D, and had a 2 month hang over from it. I hope I never have to work with it again(although for the career I'm going into, there's little chance of that).

The reason for the void pointer is to store anything. The problem with templates is that there's a copy of the code for every time that template is used. The void pointer allows you the flexibility to just code one class, and use it to store anything. In a PC environment, it's not that critical, but if you're worried about memory or working on a console, then you might consider the void pointer method. Again, I really can't argue either way, it really depends on your situation.

Monqui

Yes, some of those languages are used, Jak II also used a LISP variant for some of the AI. I'm just glad they aren't main coding languages. I have a hard enough time deciphering some C Macros...

[addsig]




Quote
Re: Leaks
Posted by Monqui on Sun Feb 22nd at 3:16pm 2004


GOAL is the LISP variant that they made especially for programming games (which is actually really weird because they still used LISP for coding other parts of the game).

"Of the 1.2 million lines of code, roughly 900,000 lines are written in GOAL. GOAL is a programming language based on LISP or rather Scheme (which is a dialect of LISP)."

But in all honesty- once you actually start using these languages, it becomes so damn simple to decipher. Plus, there are only about 8 pre-made functions, so it's a snap to learn. Overloading becomes almost a joke (wanna overload +? do this: (define + *) (+ 3 4), it'll return 12). Functions can be passed as parms, which eliminates the need in java to have those annoying gimpy classes that only hold a function that you want to overload for an interface, since you can just pass it into the function that needs it directly (ex: (apply + '(1 2 3 4 5)) applys the + operator to all the elements in the list given. + is a parameter of apply).

I'll stop ranting, but the languages are gems, I love 'em. [addsig]




Quote
Re: Leaks
Posted by Crono on Mon Feb 23rd at 4:38am 2004


? quote:
I've worked with D3D, and had a 2 month hang over from it. I hope I never have to work with it again(although for the career I'm going into, there's little chance of that).


....I'm sorry [addsig]





Post Reply