[Implemented] Compiler features

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

[Implemented] Compiler features

Post by Polo »

Hi,
I've some request for the compiler :
One, not really important, but just wondering : why, in pb, we use the name of "procedure" instead of "function" like in the other basics ? Not important, but i just wanted to know :)
The other one, much more important, bu Fred already know it i think : I would like to get the possibility to add optionals parameters in a procedure, like in Blitz, and if possible to put it compatible with Tailbite :)

Code: Select all

Procedure MyFunction (param1,param2,optionalparam=0)
Endprocedure
Blade
Enthusiast
Enthusiast
Posts: 362
Joined: Wed Aug 06, 2003 2:49 pm
Location: Venice - Italy, Japan when possible.
Contact:

Re: Compiler features

Post by Blade »

Because functions and procedures are the same thing. The only difference is that the former returns a value.
So if you need a procedure, just write a function and do not return a value, or vice-versa :)
IMHO
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Yeah, I know they are the same things, that's why i'm wondering why not having them called Function :) But i don't really care, i just wanted to know :)
DarkDragon
Addict
Addict
Posts: 2345
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

Because some people say proc instead of func and so Windowfunc became Windowproc. :P
bye,
Daniel
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

because gfabasic called them procedures?

:-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
johndehope3
New User
New User
Posts: 9
Joined: Tue Jan 13, 2004 7:00 am

Why call them anything at all?

Post by johndehope3 »

What I don't understand is why we have to call them anything at all? Instead of this...

Code: Select all

Procedure.s MyName() ... EndProcedure
What's wrong with this...

Code: Select all

MyName.s() ... EndProcedure
While I'm on the topic, how about just End instead of EndProcedure, EndIf, etc.
Also, why not Return instead of ProcedureReturn?
I think this would go a long way towards making PureBasic easier to code in.
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

johndehope3,

I rather like the use of the different End syntaxes. It makes intention much easier.

Ruby just uses plain end and this can cause problems with matching ends if my whitespace ever goes out of line. This is a particular problem if code is being copied.

If the extra typing is bothering you just switch to japbe and let autocompletion take care of it.
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Anyway i hope fred plans to work on the optional parameter thing, because it would be a lot useful !!
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Re: Why call them anything at all?

Post by freedimension »

johndehope3 wrote: What's wrong with this...

Code: Select all

MyName.s() ... EndProcedure
Answer:

Code: Select all

Proc1()
;Do weird things here
Proc2()
;Do even more weird things
EndProcedure
Now, what is the Procedure and what is just a procedure call?
<°)))o><²³
wcardoso
User
User
Posts: 80
Joined: Fri Apr 25, 2003 5:06 pm
Location: Uruguay

Post by wcardoso »

Well I think EndProcedure, EndIf, etc. is better than simply End because when the source file becomes bigger you can undestand more clearly the body of loops, procedures, etc. Specially if there are deep nesting
with love from Uruguay
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: Why call them anything at all?

Post by Psychophanta »

freedimension wrote:
johndehope3 wrote: What's wrong with this...

Code: Select all

MyName.s() ... EndProcedure
Answer:

Code: Select all

Proc1()
;Do weird things here
Proc2()
;Do even more weird things
EndProcedure
Now, what is the Procedure and what is just a procedure call?
What about EndProcedure Proc1() :?:
BTW, i guess Fred preferred "Procedure" instead "Function" because he is a native french speaker :wink:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Post by nco2k »

Code: Select all

Procedure Name()
  ;
EndProcedure
is good, the way it is... :roll:

c ya,
nco2k
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

>Psycho : I'm also native french speaker, and in french, instead of function we would say "fonction", but procedure ?? I don't like this word :)
But i don't care ;)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Are you sure "Procedure" come not from french ??
"Bureau" is a word used in english, but it comes from french too.
Well, anyway then "Procedure" sure comes from Pascal computer language, don't?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

but anyway, a procedure RETURNS something, and a function DOES NOT!!!

so, if we change it, it would become OUT of standard, and we would have to change our source too! [not the hardest change, though]

thats the difference and it is in most other basics too!
Post Reply