473,511 Members | 15,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Function return values

guy
It would be really nice if there was an option that warned the developer that calls to functions did not handle the returned value, or alternatively threw a compilation error.
I have been caught so many times by witing something like
Split(myString,",")
instead of
MyArray = Split(myString,",")
(or maybe it is there and I havent found it?)

guy
Jul 21 '05 #1
4 1510
On Wed, 30 Jun 2004 03:58:01 -0700, guy wrote:
It would be really nice if there was an option that warned the developer that calls to functions did not handle the returned value, or alternatively threw a compilation error.
I have been caught so many times by witing something like
Split(myString,",")
instead of
MyArray = Split(myString,",")
(or maybe it is there and I havent found it?)

guy


The simple explanation is that it's not an error. Although a warning might
be appropriate.

For the split function, you don't necessarily need to assign the return to
a variable. While I'm not saying that you should use it in this manner,
you can use it like this:

'Display the 3rd token in the string
MsgBox(Split(myString,",")(2))

or

'Assigns the 5th token of the string to the variable MyToken
Dim MyToken As String = Split(myString,",")(4)
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Jul 21 '05 #2
> guywrote:
It would be really nice if there was an option that warned the
developer that calls to functions did not handle the returned value,
or alternatively threw a compilation error.
I have been caught so many times by witing something like
Split(myString,",")
instead of
MyArray = Split(myString,",")
(or maybe it is there and I havent found it?)

guy


I always end up doing "SomeString.Replace(...." instead of "SomeString
= SomeString.Replace(...".

I think a compiler warning for these is entirely reasonable. If
Microsoft hears about it, I'm sure they would agree. (Is it possible
to get feedback to Microsoft on this stuff? I've tried submitting
bugs, but there was no straightforward way to do this, so maybe
suggestions are out of the question).
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Jul 21 '05 #3
guy
Jimi,
thanks for your support:-)
guy

"Jimi" wrote:
guywrote:

It would be really nice if there was an option that warned the
developer that calls to functions did not handle the returned value,
or alternatively threw a compilation error.
I have been caught so many times by witing something like
Split(myString,",")
instead of
MyArray = Split(myString,",")
(or maybe it is there and I havent found it?)

guy


I always end up doing "SomeString.Replace(...." instead of "SomeString
= SomeString.Replace(...".

I think a compiler warning for these is entirely reasonable. If
Microsoft hears about it, I'm sure they would agree. (Is it possible
to get feedback to Microsoft on this stuff? I've tried submitting
bugs, but there was no straightforward way to do this, so maybe
suggestions are out of the question).
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Jul 21 '05 #4
Not a long time ago, I recommended here to invent an Attribute
[MustUseReturnValue()] or something similar.
The compiler should give a warning if you do not use the return value of a
method marked with this Attribute.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu || http://www.deutronium.tk
"guy" <gu*@discussions.microsoft.com> schrieb im Newsbeitrag
news:A0**********************************@microsof t.com...
It would be really nice if there was an option that warned the developer that calls to functions did not handle the returned value, or alternatively
threw a compilation error. I have been caught so many times by witing something like
Split(myString,",")
instead of
MyArray = Split(myString,",")
(or maybe it is there and I havent found it?)

guy

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4935
by: Penn Markham | last post by:
Hello all, I am writing a script where I need to use the system() function to call htpasswd. I can do this just fine on the command line...works great (see attached file, test.php). When my...
8
2778
by: Nick Coghlan | last post by:
Time for another random syntax idea. . . So, I was tinkering in the interactive interpreter, and came up with the following one-size-fits-most default argument hack: Py> x = 1 Py> def...
8
29017
by: Tweaxor | last post by:
Hey, I was trying to figure out was it possible in C to pass the values in an array from one function to another function. Is the possible in C? ex. y is the array that holds seven values If...
14
1809
by: Mr Newbie | last post by:
I am often in the situation where I want to act on the result of a function, but a simple boolean is not enough. For example, I may have a function called isAuthorised ( User, Action ) as ?????...
4
2480
by: Tony Lownds | last post by:
(Note: PEPs in the 3xxx number range are intended for Python 3000) PEP: 3107 Title: Function Annotations Version: $Revision: 53169 $ Last-Modified: $Date: 2006-12-27 20:59:16 -0800 (Wed, 27 Dec...
6
3747
by: srini4vasan | last post by:
Hi, Is that possible to return two values from a functions at a time. ie.,Can a function return two values at a time. if() { return } else
11
3540
by: aarklon | last post by:
Hi all, I have heard many discussions among my colleagues that main is a user defined function or not. arguments in favour:- 1) if it is built in function it must be defined in some header...
4
2468
by: barcaroller | last post by:
I am trying to adopt a model for calling functions and checking their return values. I'm following Scott Meyer's recommendation of not over-using exceptions because of their potential overhead. ...
2
3653
ADezii
by: ADezii | last post by:
The incentive for this Tip was an Article by the amazing Allen Browne - I considered it noteworthy enough to post as The Tip of the Week in this Access Forum. Original Article by Allen Browne ...
0
7245
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
7356
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
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7512
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...
1
5069
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
3227
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
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
449
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.