can C++ sytanx like this

H

hkg35

if ( a == 3 ) ---> if( a is 3 )
if ( a != 3 ) ---> if ( a not 3 )
if( a > b && b > c ) ---> if ( a > b > c ) , if( a > b and b >c )
if( a > b || b > c ) ---> if ( a >b or b > c )

those are more human readable, I guess
I know some can be done be "Macro" , and some
some might hard for compiler implementation, but does it make sense to
both human & computer ?
if so why not, please !

and we need default value on function, not only from the end
like this : my_function ( default, default, 0 ); can we ?
 
F

Frederick Gotham

if ( a == 3 ) ---> if( a is 3 )
if ( a != 3 ) ---> if ( a not 3 )
if( a > b && b > c ) ---> if ( a > b > c ) , if( a > b and b >c )
if( a > b || b > c ) ---> if ( a >b or b > c )

those are more human readable,


Yes they are, but programming code is not a conversation. I think you'll find
that symbolic operators are more prefereable for actual code.

and we need default value on function, not only from the end
like this : my_function ( default, default, 0 ); can we ?


I believe they are adding such functionality to the language.
 
R

Ron Natalie

if ( a == 3 ) ---> if( a is 3 )
if ( a != 3 ) ---> if ( a not 3 )
if( a > b && b > c ) ---> if ( a > b > c ) , if( a > b and b >c )
if( a > b || b > c ) ---> if ( a >b or b > c )

those are more human readable, I guess
I know some can be done be "Macro" , and some
some might hard for compiler implementation, but does it make sense to
both human & computer ?
if so why not, please !

and we need default value on function, not only from the end
like this : my_function ( default, default, 0 ); can we ?

Oh please don't. Bourne used all these hideous macros to change
C into another language and it made working on his code nearly
impossible. If you don't like C++, go find another language.

By the way, there exist a few alternate tokens (mostly to
get around character set issues).
if(a not_eq 3)
is perfectly valid as is
if( a > b or b > c)
if(a > b and b > c)

Perhaps you should learn how to use C++ fully before deciding it
needs changing.
 
F

Frederick Gotham

Ron Natalie posted:
Oh please don't. Bourne used all these hideous macros to change
C into another language and it made working on his code nearly
impossible.


Would a simple "Find/Replace" facility not fix the problem in a matter of
minutes... ? E.g.

Find: is
Replace: ==
 
R

Ron Natalie

Frederick said:
Ron Natalie posted:



Would a simple "Find/Replace" facility not fix the problem in a matter of
minutes... ? E.g.

Find: is
Replace: ==

Well there were a lot of them and it left the white space all hosed up
as well. Someone else up at Bell Labs fortunately translated it all
back into regular C somewhere before System VR2 came out.
 
B

Bart

Frederick said:
Ron Natalie posted:



Would a simple "Find/Replace" facility not fix the problem in a matter of
minutes... ? E.g.

Find: is
Replace: ==

<sarcasm>Of course no sane person would ever use the word "is" in a
comment.</sarcasm>

Regards,
Bart.
 
J

jjds101

Bart said:
<sarcasm>Of course no sane person would ever use the word "is" in a
comment.</sarcasm>
Heh, or you could have something like:

istream& operator >> (istream& is , myClass& mc );
 
H

heltena

and we need default value on function, not only from the end
like this : my_function ( default, default, 0 ); can we ?

do you like it?

class my_function_params {
public:
my_function_params()
: m_param1(default_value_for_param1)
, m_param2(default_value_for_param2)
... () {
}
my_function_params& param1(param1_type new_value) { m_param1 =
new_value; return *this; }
my_function_params& param2(param2_type new_value) { m_param2 =
new_value; return *this; }
...
param1_type param1() { return m_param1; }
param2_type param2() { return m_param2; }
...
private:
param1_type m_param1;
param2_type m_param2;
...
};

void my_function(my_function_params params) {
// use params.param1(), ...
}

my_function( my_function_params().param3(56).param5("hi!") );
 
F

Frederick Gotham

Victor Bazarov posted:
I think he forgot to mention

#undef is

right before that line...


So basically you'd need something like:

After the macro definition of "is":

(1) Search for "is"
(2) If "/*" is encountered beforehand, then disable the find/replace
algorithm until "*\" is found.
(3) If "#undef is" is found, then abandon the search.
(4) Finally, for all other times where "is" is found, replace it with ==.
 
B

Bart

Frederick said:
So basically you'd need something like:

After the macro definition of "is":

(1) Search for "is"
(2) If "/*" is encountered beforehand, then disable the find/replace
algorithm until "*\" is found.
(3) If "#undef is" is found, then abandon the search.
(4) Finally, for all other times where "is" is found, replace it with ==.

Of course, with the additional "minor" provisions for string litterals,
and // comments and line-continuations in // comments, and the
possibility of having #undef inside #if... blocks, or the possibility
of having the word 'is' on a #error line, or a header named "is", it's
a very "trivial" task. Like you said, a matter of minutes...

Regards,
Bart.
 
T

Tom Smith

Frederick said:
(e-mail address removed) wrote:
>


I believe they are adding such functionality to the language.

Is this definite? Do you know when the new "functionality" is planned for? Most
importantly, are they adding a lambda keyword?

(The single thing I hate most about C++ is the huge amount of fiddle needed to
write, say, a one-off function to pass to a generic algorithm, eg (deliberately
stupid example), writing this:

struct print: public std::unary_function <void, int>
{
void operator() (int x) { std::cout << x << std::endl(); };
};

void some_other_function()
{
std::vector<int> v;
// ... //
for_each(v.begin(), v.end(), print());
// ... //
}


instead of (say) this:

void some_other_function()
{
std::vector<int> v;
// ... //
for_each(v.begin(), v.end(), int lambda(int x)
{ std::cout << x << std::endl(); } );
// ... //
}

) <-- this bracket was opened a long way back...


Tom
 
T

Tom Smith

Tom said:
Is this definite? Do you know when the new "functionality" is planned
for? Most importantly, are they adding a lambda keyword?

I believe (incidentally) that Norvig, amongst others, is very keen on this.

T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top