Proc and Procedure
Author |
Message |
Guest
|
Posted: Sun May 28, 2006 12:18 pm Post subject: Proc and Procedure |
|
|
Well I noticed a few "shortcuts" when I first started Turing. Proc = Procedure, fcn = function. So I'm asking, when should one or the other be used, or does it matter? Like should proc be used when your like drawing something, or should procedure only be used when you make a formula that will be called on several occasions? Enlighten me. ![Twisted Evil Twisted Evil](http://compsci.ca/v3/images/smiles/icon_twisted.gif) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sun May 28, 2006 12:22 pm Post subject: (No subject) |
|
|
They do the exact same thing. It's a matter of taste. |
|
|
|
|
![](images/spacer.gif) |
codemage
![](http://usera.imagecave.com/codemage/codemage-small.gif)
|
Posted: Mon May 29, 2006 8:07 am Post subject: (No subject) |
|
|
Pick your favourite one and stick with it - don't use them interchangeably. |
|
|
|
|
![](images/spacer.gif) |
Guest
|
Posted: Mon May 29, 2006 8:14 am Post subject: (No subject) |
|
|
Well I use both of them, like mostly proc I will use to change a major part of my program, and procedures will be called frequently in my program. |
|
|
|
|
![](images/spacer.gif) |
NikG
|
Posted: Mon May 29, 2006 2:34 pm Post subject: (No subject) |
|
|
vahnx wrote: Well I use both of them, like mostly proc I will use to change a major part of my program, and procedures will be called frequently in my program.
Your reason doesn't make much (if any) sense... The code is treated exactly the same whether you save proc or procedure.
Anyways, if for some reason it helps you... I guess keep it up. |
|
|
|
|
![](images/spacer.gif) |
Guest
|
Posted: Mon May 29, 2006 3:08 pm Post subject: (No subject) |
|
|
I ment, I use 'proc' as the main procedure(s) in a program, such as towns, etc. and 'procedure' will be used to change small parts of the program. That's how I use them. |
|
|
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon May 29, 2006 3:55 pm Post subject: (No subject) |
|
|
It's not entirely odd to use the two different syntaxes that do the exact same thing for different purposes. Let me give you a widespread example of this.
In Ruby, blocks are defined between do and end or between { and }. They are treated (almost) identically by the interpreter.
Some people use {} for everything, while others use do..end for everything. One convention (the one I use) uses {} for blocks on a single line, and uses do..end for multi-line blocks. Another convention (newer, gaining popularity) is to use {} for blocks that return a particular value (no side-effects) and do..end for things that modify state (have side effects).
Using two different syntaxes that do the same thing can be a good way of classifying what each section of your code is for. |
|
|
|
|
![](images/spacer.gif) |
Guest
|
Posted: Mon May 29, 2006 5:31 pm Post subject: If VS Switch |
|
|
What about if and elsif[b] versus [b]switch and case. Im not sure if switches and cases are in Turing, but you know what I mean, I think. Are those the same pretty much? |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Mon May 29, 2006 5:52 pm Post subject: Re: If VS Switch |
|
|
vahnx wrote: What about if and elsif[b] versus [b]switch and case. Im not sure if switches and cases are in Turing, but you know what I mean, I think. Are those the same pretty much?
In Turing, "switch" and "case" are "case" and "label", respectively.
No, if's and switch/case/label are very different. For example, I can set up an if statement to check if x is greater than 46. Using a (Turing) case construct, this is impossible, because case constructs only compare using the = operator, not using > or any other operator. |
|
|
|
|
![](images/spacer.gif) |
|
|