[Gambas-devel] Functions and subs

Kadaitcha Man nospam.nospam.nospam at ...176...
Tue Dec 8 12:42:18 CET 2009


2009/12/8 Ron <ron at ...572...>:

> While checking my large codebase I have noticed that I had some routines
> of type SUB that returned something  (SUB blabla () AS String etc) and I
> have FUNCTIONS who don't return anything.... (ie no RETURN xxx or AS xxx
> defined). Which is wrong of course.

No, it's normal. You're not going to like this if you've had a few beers, mate:

Functions return a value. Procedures do not.

A procedure is a method that returns nothing, a subroutine.

A function is a procedure that returns a value.

BWAHAHAHAHAHAHAHAHA! Truly, no joke.

If you don't know why I'm laughing it's because the implication is
that a function is a subroutine that returns a value.

You need to start thinking in terms of method and procedure, not Sub
and Function. If you don't do that, when you actually read the Gambas
documentation you'll be horribly confused as to why a procedure is
documented as being a SUB.

BUT WAIT! It gets worse. A method is a specific type of procedure.

Does that confuse and confound you much? It should.

Sub and Function become superfluous when you start thinking in terms
of method and procedure,




More information about the Devel mailing list