473,461 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Call: Is it necessary?

lotus18
866 512MB
Hello World

Using a Call is it necessary? You can call a function without using that keyword right? Second question, which performs faster, using a Call or not?

Rey Sean
Jan 28 '08 #1
11 1440
debasisdas
8,127 Expert 4TB
Specifying CALL is optional and is agood practise to use in programming.

That does not involve any performance issue.
Jan 28 '08 #2
Killer42
8,435 Expert 8TB
Specifying CALL ... is agood practise to use in programming.
That is entirely a matter of opinion. You would hardly expect to use CALL before every statement, so why pick out particular ones?

Surely the whole point of an extensible language is that the extensions are integrated into it seamlessly, and don't require special coding to use.
Jan 29 '08 #3
cugone
20
Using the Call statement is more of a readability preference than anything.

Be aware though, that it's only safe to use it on Subroutines, not Functions, as when it's used on Functions it causes the returned value to be ignored.
Jan 29 '08 #4
Killer42
8,435 Expert 8TB
Using the Call statement is more of a readability preference than anything.
I'm curious about which way you mean that. I generally find the code much more readable without the Call.
Jan 29 '08 #5
debasisdas
8,127 Expert 4TB
My understanding is CALL should be used to call sub procedures not other event procedures and functions.

It make the code more readable in the sense that while going through the code it can be easily find out . It specifies that anything following that keyword is a sub procedure. It specially comes handy while someone else is going through your code. Specially in maintenance projects.
Jan 29 '08 #6
lotus18
866 512MB
It specially comes handy while someone else is going through your code. Specially in maintenance projects.
You have the point. : )

Rey Sean
Jan 29 '08 #7
werks
220 100+
Hello World

Using a Call is it necessary? You can call a function without using that keyword right? Second question, which performs faster, using a Call or not?

Rey Sean
I agree with debasisdas, it is much easier to identify if you use Call


Better Than Yesterday ^^
Jan 29 '08 #8
jamesd0142
469 256MB
For what it's worth i agree with killer42, I prefer to read and write code without writing "call".

I believe it's a preference that will differ between programmers.

And here's my reason for posting:

Is it right if you use call to call a function the return value is ignored? I was unaware of this.

Does this not remove the whole point of calling a function?
Jan 29 '08 #9
Killer42
8,435 Expert 8TB
For what it's worth i agree with killer42, I prefer to read and write code without writing "call".

I believe it's a preference that will differ between programmers.
My point is that with an extensible language such as this, once you create a Sub or Function it effectively becomes part of the language. It's a "black box", presumed to have been tested and working. There should be no need to differentiate by using a special type of call. The name of the routine should be enough to tell you what it does. If there's any question about where the routine comes from, a simple keypress will tell you.

Is it right if you use call to call a function the return value is ignored? I was unaware of this.

Does this not remove the whole point of calling a function?
Well, yes and no. If you need the return value, then sure, it defeats the purpose. But keep in mind that since the function can contain any code you like, it may actually do something. You may want to treat it like a Sub in certain circumstances and not bother with a returned value.

The MsgBox function is a prime example. You can use it to prompt the user and determine what button they clicked. Or you can just show a message and wait for the user to click OK. Do you need to know that they clicked OK?

Examples...
Expand|Select|Wrap|Line Numbers
  1.   Dim UserResponse As Long
  2.  
  3.   ' Before performing some action...
  4.   UserResponse = MsgBox("Are you sure?", vbYesNoCancel, "Confirm Action")
  5.  
  6.   ' After performing some action...
  7.   MsgBox "Finished!"
  8.  
Jan 29 '08 #10
kadghar
1,295 Expert 1GB
Hope any of you know why this happens.
Feb 12 '08 #11
Killer42
8,435 Expert 8TB
Hope any of you know why this happens.
Yes, that was a very simple one. The OP had put unnecessary parentheses around the argument list in the "call". All they needed was to remove them.
Feb 12 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray =...
39
by: Randell D. | last post by:
Folks, I'm sure this can be done legally, and not thru tricks of the trade - I hope someone can help. I'm writing a 'tool' (a function) which can be used generically in any of my projects. ...
4
by: Christian | last post by:
From a not even newbie: Without knowing much about Python (yet) I'm trying to install the CMS Zope via FTP (with the well documented changes to make it work on an Apache server). By birth Zope...
24
by: Jazper | last post by:
hi i have this problem. i made a class deverted by CRootItem with implementation of IDisposable-Interface. i made a test-funktion to test my Dispose-Method.... but when set a breakpoint in my...
1
by: Robert Ludewig | last post by:
I have sucessfully imported and compiled a complex MFC 6.0 project from vc++6.0 (MFC6.0) into vc++ 8.0 (MFC 8.0). It contains several subprojects (libs and dlls). In vc++ 6.0 those project linked...
16
by: Jordan S. | last post by:
I have a VBScript that runs on the server. I want to call that script from an ASP.NET Web application. How can I do that? Thanks!
7
by: dragoncoder | last post by:
Hello experts, I have the following code me. =cat mystring.h #include<iostream> using namespace std; class mystring {
4
by: Frank Lund | last post by:
Should we call .Dispose() every chance we get... on every object that exposes .Dispose()... and every time we have such an object? For example, is it true that *every* time I create a DataTable...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.