>> 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.

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.

<_<

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.

>> 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.

#include<iostream>

using namespace std;


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

its output is 5.

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.

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;
}

ok...I was just pointing out that n was assigned a value...

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

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

?? No, It's the opposite:

Sorry, thanks for catching that..

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.

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.

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;
}

ya'll made my head explode

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

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

.. you can overload constructors in java

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.

lol.. naw, I'm starting to get used to it now ;) Although, I still laugh occasionally :D

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?)

commented: hehe :D +9

yee works, just don't over use it :)

>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.

> 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.

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.

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.

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.

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".

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!");
}
commented: Thanks for that correction :) +9

>_< 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.. :(

So is this thread still about myspace?

;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.