0

>> assert ((time - t1) < NOT_LONG);

Unless time is a local variable which gets updated all the time I would expect that should be time()-t1 ...
>> bebo.wonder_what_the_what_that_is();
Best not ask.

0

Unless time is a local variable which gets updated all the time I would expect that should be time()-t1 ...

er... >_>

In Cavascript++ the parenthesis for function parameters are not mandatory.

I'm suprised I missed that though. It's considered bad form among the few existing Cavascript++ programmers to leave them out. That sort of ambiguity lost Cavascript++ alot of support.. I think they renamed it to Palaverscript eventually.

<_<

0

Um.. I do not think so, I think it just assigns the value.

I'm fairly sure from most of what I've been reading recently on programming that the expression is calculated, then if it doesn't result in a 0, it's treated as a true statement. (In C, at least; you may be correct for other languages.)

If I am incorrect on this, please point me to the appropriate documentation so that I might learn more.

0

>> In Cavascript++ the parenthesis for function parameters are not mandatory.

How does one tell the difference between a function and variable then? That sounds like not a great feature.

0
#include<iostream>

using namespace std;


int main()
{
    int n=0;
    if(n=5){};
    cout<<n<<"\n";
    return 0;
}

its output is 5.

0

How does one tell the difference between a function and variable then? That sounds like not a great feature.

One makes sure one doesn't use the same name for a variable and a function... the same principle is in other langauges, in Javascript you use something = function(); to call a function and set 'something' to the return, and something = function; to make 'something' a pointer/reference to that function... That works because functions are objects... But, parenthesis are mandatory for function calls.

Even in C++, you can't use a member variable name that's the same as a member method name; it would be difficult to disambiguate a pointer to a variable and a pointer to a function otherwise...

VB actually has non-mandatory parenthesis for function parameters in some circumstances.. It's not a great feature though admitadly.

Perhaps! time is an in-scope object with overloaded operators such that it always returns the result of the function time() +-/* rhs ...

Or perhaps... I forgot to add the parenthesis.

0

I'm fairly sure from most of what I've been reading recently on programming that the expression is calculated, then if it doesn't result in a 0, it's treated as a true statement. (In C, at least; you may be correct for other languages.)

If I am incorrect on this, please point me to the appropriate documentation so that I might learn more.

This is true.

#include<iostream>
using namespace std;
int main()
{
int n=0;
if(n=5){};
cout<<n<<"\n";
return 0;
}
its output is 5.

That doesn't disprove that the statement n=5 doesn't evaluate true; it is indeed an assignment, but it will evaluate to true:

this is better proof, of the statement by EnderX being correct.

#include<iostream>
using namespace std;
int main()
{
    int n=0;
    if(n=5){
    cout << "yes, n=5 is true" << endl;
    };
    cout<<n<<"\n";
    return 0;
}
0

In java, "==" is used as an "equal to" operator, and thus is used for comparison. The "=" is used to assign a value..

[edit] Whoops.. mistake.. Thanks Matt

0

In java, "=" is used as comparison, while "==" is used to assign a value..

?? No, It's the opposite:

int n = 5; //assignment
if( n==5 ) //comparison.
{
  explode();
}

In MS Visual Basic.. I think there is only a '=' operator; and its functionality depends on usage context:

Dim n as Integer
n = 5;
If n = 5
 Call explode
End If
0

In java, "==" is used as an "equal to" operator, and thus is used for comparison. The "=" is used to assign a value..

Ditto for C. Which makes things interesting for me, because while I'm trying to learn that, I'm also programming with Delphi, which uses the Pascal syntax for those.

Pascal -
Assignment Operator is :=
Equality test is =

I've found myself using := and == within a couple of lines of one another, in both.

0

I always thought it would be confusing to learn multiple programming languages.. everything would just seem to run together.. But, I guess it's like learning another spoken language, and you would be able differentiate after experience.

0

How does one tell the difference between a function and variable then? That sounds like not a great feature.

One makes sure one doesn't use the same name for a variable and a function... the same principle is in other langauges, in Javascript you use something = function(); to call a function and set 'something' to the return, and something = function; to make 'something' a pointer/reference to that function... That works because functions are objects... But, parenthesis are mandatory for function calls.

Yep, like in C/C++, you can't declare a function and a variable with the same name in the same scope (in fact, you can't declare any objects with the same name in the same scope)... I think this program pretty much says it all:

#include <iostream>

void hello(int num);
int hello; // "error: 'int hello' redeclared as different kind of symbol"

int main() {
    
    int hello = 3;
    void (*func)(int);
    
    func = hello; // "error: invalid conversion from 'int' to 'void (*)(int)'"
    func = ::hello(); // "error: too few arguments to function 'void hello(int)'"
    func = ::hello(int); // "error: expected primary-expression before 'int'"
    func = ::hello;
    func(hello);
    (*func)(hello);
    
    return 0;
}

void hello(int num) {
    std::cout << "Num = " << num << std::endl;
}
0

>> func(hello);
Doesn't that flag an error? Isn't that like using an 'overloaded consturcor' ... after construction?

>> (*func)(hello);
func->hello :P Heh.

0

You can too in C++, but I don't think ye #include <iostream> in java, do ye?

Twice in one post, Josh. I should get paid.

1

If you'd like I could spice it up for you .... I mean for yee (see, two e's ... I've been working on it for a while. What'a think?)

Votes + Comments
hehe :D
0

>Doesn't that flag an error?
Nope. The original form in C was (*function_pointer)(arguments), but a new feature was added to the standard, so function_pointer(arguments) can be used, and that is the preferred method.

0

> In java, "==" is used as an "equal to" operator
Only when you need to compare references or primitives. In case of objects, you use the function 'equals' to compare values.

0

That doesn't disprove that the statement n=5 doesn't evaluate true; it is indeed an assignment, but it will evaluate to true:

this is better proof, of the statement by EnderX being correct.

#include<iostream>
using namespace std;
int main()
{
    int n=0;
    if(n=5){
    cout << "yes, n=5 is true" << endl;
    };
    cout<<n<<"\n";
    return 0;
}

Not all assignments evaluate to true.

if(x = 0)
    puts("This won't be executed");
else
    puts("I am sure of this.");

Its the value to which the variable evaluates to which influences the branching and not the assignment.

0

Only when you need to compare references or primitives. In case of objects, you use the function 'equals' to compare values.

yep, as in

java.equals(awesome)

in which java and awesome are of the same type, say string.

0

yep, as in

java.equals(awesome)

in which java and awesome are of the same type, say string.

If they're both strings, you're either setting the String java to "awesome" or the String awesome to "java" at some point before making the comparison*.. which stunts the results of such a test somewhat, does it not? =P

*edit: or maybe anything else. silly assumptions in my head there... still... they'd have to be the same thing.. java can't equal awesome.

0

As I said, they have to be of the same type

String java = "java";
String awesome = "awesome";

java.equals(awesome);

Following this, java would now equal "awesome", and awesome would still equal "awesome".

1

As I said, they have to be of the same type

String java = "java";
String awesome = "awesome";

java.equals(awesome);

Following this, java would now equal "awesome", and awesome would still equal "awesome".

>_< boolean Object.equals( Object ) is a comparator, not an 'assigner'

as in:

String java = "java";
String awesome = "awesome";

if(java.equals(awesome))
{
  System.err.println("An unexpected error has occured!");
}
Votes + Comments
Thanks for that correction :)
0

>_< boolean Object.equals( Object ) is a comparator, not an 'assigner'

as in:

String java = "java";
String awesome = "awesome";

if(java.equals(awesome))
{
  System.err.println("An unexpected error has occured!");
}

ahh derr.. what a dumbass mistake. In my example you would use java=example to reassign value.. I apologize for dumbing up this thread.. :(

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.