- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
That is the way we were taught to write COBOL
Admin
I don't like the variable name convention: I read that the original intention was
Which = Which + (HowMany * Which)
By the way, += was a good way to do pointer arithmetic in languages which didn't directly support structured data arrays, and is an important construct when doing hardware integration where you want to specify that the receiving variable is not being read.
In all other situations, it's a handy contraction for people who can't type.
Admin
All variables were 'by ref', and numbers were treated as pre-assigned variables (like some kinds of 'constants' in C). This made the compiler smaller and simpler, but at the cost of allowing you to overwrite constants like 1 or 10.
And if you think THAT was interesting, many of the machines these FORTRANS ran on had no memory protection at all: an error in an array index would allow you to overwrite the operating system, bringing that down as well. It didn't make debugging any easier, but at least you KNEW that you had a bug....
(david)
Admin
well, according to our software design and development school HSC syllabus, a function is a module of a system, and should do a specific, well documented, well defined process. Intrinsic documentation and internal documentation is also important, as the programmer is able to debug easily. Also, functional decomposition allows for easy debugging as the bug can be tracked down to a specific location.
so therefore, thats a perfectly good function. it does a well defined specific action, it adds two numbers together.it also has intrinsic documentation, as it has good variable and function names.
would someone please get us rid of that hsc subject?
Admin
so, like, where's the comment?
Admin
on my way back out of this tangle by repeatingly clicking on the back button which is actually a left button, it occured to me that I bet a bunch of you have never wondered how long it takes a dead cat to begin smelling bad.
I know!!!
I just bet you dont.
John
Admin
I think you're attempting to illustrate the different between macros and function, but nonetheless you just wrote
foo() = foo() + 1;
(a) You need an lvalue (c) It makes no sense to pass foo() by reference
No, it's an array access based on the result of a function, so it's fine. arr[foo()] = arr[foo()] + 1. Nothing wrong with that.
(b) You need to store the result somewhere anyway, so it is no more complicated to write a = a + b
No you don't, you just call the function and it modifies the first parameter. So you only need to put it in once, rather than twice.
Admin
"Is it that hard" wrote - <font color="#0000ff">What is 8</font>
Well at the most basic level, 8 is a number. It is one more than 7, and one less than 9.
If you read Terry Pratchett you'll find that 8 is quite special.
8 appears in lots of places. I'm sure you can find a special mention of 8 in whatever culture/religion you practice. ;-)
Admin
This was my thought exactly. Instead of taking advantage of an operator within the language, lets write a method or a 'sub' to do exactly the same thing. It would almost be as good as writing your multiply function that does nothing more then the '*' operand:
<font face="Courier New">function multiply(byref which as integer, byval howmuch as integer)
which = which * homuch
end function
<font face="Times New Roman">which is </font></font><font face="Times New Roman">absolutly useless. It only complicates the code and increase memory overhead since the function call would require space on the heap to pass the pointer of which and howmuch value and THEN actually perform the action/operation to make the addition.</font>
<font face="Courier New">
</font>
Admin
Well, it doesn't need to return anything. Which is passed ByRef, so adding to Which adds to it in the original scope of the variable.
Admin
-double post alert-
Well, the post is half right. IL is far more advanced than java bytecode, but that doesn't mean it preforms better. Also, IL _can_ be put on a chip -- MSN Direct watches have the framework.
Admin
Yes, Virginia, you should not use return values to return something from a function. Interestingly enough, VB.NET's method of making an indexer allows from some really strange code. Try this one ... it works!
<FONT face="Courier New">Public Property SomeValue(ByVal UselessCrap As Integer, _
ByVal MoreUselessCrap As Integer) As String
Get
Return _someValue
End Get
Set(ByVal Value As String)
_someValue = Value
_uselessCrap = UselessCrap
_moreUselessCrap = MoreUselessCrap
End Set
End Property</FONT>
And, yes, I have run into one person (who did not understand constructors) who actually used it this way. To give some benefit of the doubt, he did add this overload of the Property to avoid lengthy signatures when attempting to return the property:
<FONT face="Courier New">Public Property SomeValue() As String
Get
Return _someValue
End Get
Set(ByVal Value As String)
_someValue = Value
End Set
End Property</FONT>
:-)
Admin
Admin
I couldn't agree more.
Admin
You've never had a function populate objects by reference and return a status code?
Admin
Please Clean the erros this computer.Thank you,
Sincerly,
Philip P Wolcott
Admin
You're passing "Which" by reference, so you're modifying the variable passed to the placeholder "Which" itself...
<FONT face=Georgia size=1>a=10;</FONT>
<FONT face=Georgia size=1>b=15;</FONT>
<FONT face=Georgia size=1>add(a,b);</FONT>
"a" now equals 35...
Admin
This function CAN make sense IF it returns something...
p.s. my captcha was truthiness! Go Colbert!!My guess is this was a replacement for a C# construct where the addition operator also returns the result of the addition:
Admin
introduce c#winsock and c#connect22computer
Admin
I debugged it.