Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: function for difference two dates

Reply
Thread Tools

Re: function for difference two dates

 
 
Ian Collins
Guest
Posts: n/a
 
      06-16-2010
On 06/16/10 09:28 PM, io_x wrote:
> [comp.lang.c,comp.lang.c++]
>
> what about one function that do difference of 2 dates?
> where date is class or struct of type
> int sec, min, ora, day, mese, anno;
> where the difference is in
> sec, min, ora, day, mese, anno
>
> #define R return


Why?

--
Ian Collins
 
Reply With Quote
 
 
 
 
Keith Thompson
Guest
Posts: n/a
 
      06-16-2010
Ian Collins <(E-Mail Removed)> writes:
> On 06/16/10 09:28 PM, io_x wrote:
>> [comp.lang.c,comp.lang.c++]
>>
>> what about one function that do difference of 2 dates?
>> where date is class or struct of type
>> int sec, min, ora, day, mese, anno;
>> where the difference is in
>> sec, min, ora, day, mese, anno
>>
>> #define R return

>
> Why?


He's been asked this before and he's answered before. If he answers
this time, I don't expect his answer to make any more sense than the
last one. (He apparently thinks R is actually better than "return";
I don't remember his rationale.)

Or, for io_x's benefit:

H's b a t b a h's a b. I h a t t, I d't e h a t m a m s t t l o.
(H a t R i a b t "r"; I d't r h r.)

--
Keith Thompson (The_Other_Keith) http://www.velocityreviews.com/forums/(E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
 
 
 
Ike Naar
Guest
Posts: n/a
 
      06-17-2010
In article <(E-Mail Removed)>,
Keith Thompson <(E-Mail Removed)> wrote:
>Ian Collins <(E-Mail Removed)> writes:
>> On 06/16/10 09:28 PM, io_x wrote:
>>> #define R return

>>
>> Why?

>
>He's been asked this before and he's answered before. If he answers
>this time, I don't expect his answer to make any more sense than the
>last one. (He apparently thinks R is actually better than "return";
>I don't remember his rationale.)
>
>Or, for io_x's benefit:
>
>H's b a t b a h's a b. I h a t t, I d't e h a t m a m s t t l o.
>(H a t R i a b t "r"; I d't r h r.)


At least io_x shows us the definitions for his silly macros.
For our benefit, could you show yours?
--
(E-Mail Removed)
SDF Public Access UNIX System - http://sdf.lonestar.org
 
Reply With Quote
 
Öö Tiib
Guest
Posts: n/a
 
      06-17-2010
On Jun 17, 12:22*pm, "io_x" <(E-Mail Removed)> wrote:
> "Ian Collins" <(E-Mail Removed)> ha scritto nel messaggionews:(E-Mail Removed)...
>
> > On 06/16/10 09:28 PM, io_x wrote:

>
> >> #define *R *return

>
> > Why?

>
> why not?


Because you will hate it when you have to deal with code of other
macro-magician with different ideas. R is only start. It goes on:

#define G *goto
#define W while
#define S switch
#define C case

Then come patterns:

#define EI else if
#define FI(END) for(int i=0; i<END; i++)

So it goes. I have seen it at its final stage. Code was readable only
for its author in raw form. Normal programmers had to let compiler to
preprocess it first to read it. Also author had difficulties to read
normal code.

> "R" it is small, many spaces saved, [more code for line an better indented]
> than for read is better than return
> at last here
>
> than "#define *R return" is not standard C or C++?
>
> you whoudl say not understand standard C or C++?


There are endless things that must compile by standard. No undefined
behavior involved:

char* hehs = "Endless fun and lulz";
unsigned dozen = 6,014; // 12
if ( -1 > dozen ) // true
{
delete this;
throw dozen[hehs]; // 'a'
}

Even as joke it is not too funny.
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-17-2010
(E-Mail Removed) (Ike Naar) writes:
> In article <(E-Mail Removed)>,
> Keith Thompson <(E-Mail Removed)> wrote:
>>Ian Collins <(E-Mail Removed)> writes:
>>> On 06/16/10 09:28 PM, io_x wrote:
>>>> #define R return
>>>
>>> Why?

>>
>>He's been asked this before and he's answered before. If he answers
>>this time, I don't expect his answer to make any more sense than the
>>last one. (He apparently thinks R is actually better than "return";
>>I don't remember his rationale.)
>>
>>Or, for io_x's benefit:
>>
>>H's b a t b a h's a b. I h a t t, I d't e h a t m a m s t t l o.
>>(H a t R i a b t "r"; I d't r h r.)

>
> At least io_x shows us the definitions for his silly macros.
> For our benefit, could you show yours?


It's just the previous paragraph with each word abbreviated to its
initial letter.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Keith Thompson
Guest
Posts: n/a
 
      06-17-2010
"io_x" <(E-Mail Removed)> writes:
> "Ian Collins" <(E-Mail Removed)> ha scritto nel messaggio
> news:(E-Mail Removed)...
>> On 06/16/10 09:28 PM, io_x wrote:
>>> [comp.lang.c,comp.lang.c++]
>>>
>>> what about one function that do difference of 2 dates?
>>> where date is class or struct of type
>>> int sec, min, ora, day, mese, anno;
>>> where the difference is in
>>> sec, min, ora, day, mese, anno
>>>
>>> #define R return

>>
>> Why?

>
> why not?
> "R" it is small, many spaces saved, [more code for line an better indented]
> than for read is better than return
> at last here
>
> than "#define R return" is not standard C or C++?
>
> you whoudl say not understand standard C or C++?


If I see

return 42;

I know what "return" means. If I see

R 42;

I have to figure out, not just what R means, but what *you* mean
by R. Sure, the #define is there, but I have to spend extra time
finding it to make sure you didn't define it as "restrict" or
"register", or "(void)".

It makes the code more difficult to read. It saves you a tiny amount
of time and costs anyone trying to read your code a great deal more
with no corresponding benefit.

Code is meant to be read by humans, especially code posted
to Usenet. Consider that, over the years, multiple people have
strongly criticized your coding style, have told you that it makes
your code more difficult to read, and in many cases have killfiled
you because of it. I have *never* seen anyone other than you say
anything positive or even neutral about it.

You demonstrate your disregard for the convenience of the people
you're asking to read your code.

For myself, I've solved the problem by not wasting my time reading it.

--
Keith Thompson (The_Other_Keith) (E-Mail Removed) <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
 
Reply With Quote
 
Seebs
Guest
Posts: n/a
 
      06-17-2010
On 2010-06-17, Keith Thompson <(E-Mail Removed)> wrote:
> It makes the code more difficult to read. It saves you a tiny amount
> of time and costs anyone trying to read your code a great deal more
> with no corresponding benefit.


I disagree.

I do not think it saves any time at all.

> Code is meant to be read by humans, especially code posted
> to Usenet. Consider that, over the years, multiple people have
> strongly criticized your coding style, have told you that it makes
> your code more difficult to read, and in many cases have killfiled
> you because of it. I have *never* seen anyone other than you say
> anything positive or even neutral about it.


I killfiled him about the second time I saw it. About the nicest thing
I could say about his posts is that some of them are at least lucid,
even though they're wrong.

I've sort of assumed he's just trolling. He's got a bit too much technical
ability to be as stupid as he acts.

-s
--
Copyright 2010, all wrongs reversed. Peter Seebach / (E-Mail Removed)
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
 
Reply With Quote
 
Dann Corbit
Guest
Posts: n/a
 
      06-17-2010
In article <(E-Mail Removed)>, (E-Mail Removed) says...
>
> "io_x" <(E-Mail Removed)> writes:
> > "Ian Collins" <(E-Mail Removed)> ha scritto nel messaggio
> > news:(E-Mail Removed)...
> >> On 06/16/10 09:28 PM, io_x wrote:
> >>> [comp.lang.c,comp.lang.c++]
> >>>
> >>> what about one function that do difference of 2 dates?
> >>> where date is class or struct of type
> >>> int sec, min, ora, day, mese, anno;
> >>> where the difference is in
> >>> sec, min, ora, day, mese, anno
> >>>
> >>> #define R return
> >>
> >> Why?

> >
> > why not?
> > "R" it is small, many spaces saved, [more code for line an better indented]
> > than for read is better than return
> > at last here
> >
> > than "#define R return" is not standard C or C++?
> >
> > you whoudl say not understand standard C or C++?

>
> If I see
>
> return 42;
>
> I know what "return" means. If I see
>
> R 42;
>
> I have to figure out, not just what R means, but what *you* mean
> by R. Sure, the #define is there, but I have to spend extra time
> finding it to make sure you didn't define it as "restrict" or
> "register", or "(void)".
>
> It makes the code more difficult to read. It saves you a tiny amount
> of time and costs anyone trying to read your code a great deal more
> with no corresponding benefit.
>
> Code is meant to be read by humans, especially code posted
> to Usenet. Consider that, over the years, multiple people have
> strongly criticized your coding style, have told you that it makes
> your code more difficult to read, and in many cases have killfiled
> you because of it. I have *never* seen anyone other than you say
> anything positive or even neutral about it.
>


First of all, as everyone knows, macros that are not simply numbers
(functional or action type) are evil. Careful construction and use can
render them useful in rare circumstance, but in general they are a bad
idea for something besides numerical constants or token pasting formats,
(and other things of that nature).

Second of all, will the maintenance programmer now realize that 13 of
the 26 letters of the alphabet have been used up and if he defines a
variable with that name it will cause the program to act in an
unexpected manner?

C tends to be terse enough. There are lots of things that are legal in
the C language, but that does not mean that we ought to do them.
(E.g. we can make an entire 64K function be nothing more than a gigantic
return statement and it will work. That does not make it a good idea).
 
Reply With Quote
 
bart.c
Guest
Posts: n/a
 
      06-17-2010

"Ike Naar" <(E-Mail Removed)> wrote in message
news:hvcj8h$l7$(E-Mail Removed)-eu.org...
> In article <(E-Mail Removed)>,
> Keith Thompson <(E-Mail Removed)> wrote:
>>Ian Collins <(E-Mail Removed)> writes:
>>> On 06/16/10 09:28 PM, io_x wrote:
>>>> #define R return
>>>
>>> Why?

>>
>>He's been asked this before and he's answered before. If he answers
>>this time, I don't expect his answer to make any more sense than the
>>last one. (He apparently thinks R is actually better than "return";
>>I don't remember his rationale.)
>>
>>Or, for io_x's benefit:
>>
>>H's b a t b a h's a b. I h a t t, I d't e h a t m a m s t t l o.
>>(H a t R i a b t "r"; I d't r h r.)

>
> At least io_x shows us the definitions for his silly macros.
> For our benefit, could you show yours?


It would be something like the following, however it doesn't really work
because the same letter is shared by many words, so I've added an index
here:

#define H he
#define S s
#define B been
#define A asked
#define T this
#define B2 before
#define A2 and
#define A3 answered
#define I if
#define A4 answers
#define T2 time
#define I2 i
#define D don
#define T3 t
#define E expect
#define H2 his
#define A5 answer
#define T4 to
#define M make
#define A6 any
#define M2 more
#define S2 sense
#define T5 than
#define T6 the
#define L last
#define O one
#define A7 apparently
#define T7 thinks
#define R r
#define I3 is
#define A8 actually
#define B3 better
#define R2 return
#define R3 remember
#define R4 rationale

--
Bartc

 
Reply With Quote
 
Ike Naar
Guest
Posts: n/a
 
      06-17-2010
In article <(E-Mail Removed)>,
Keith Thompson <(E-Mail Removed)> wrote:
>It's just the previous paragraph with each word abbreviated to its
>initial letter.


[slaps forehead] Thanks.
--
(E-Mail Removed)
SDF Public Access UNIX System - http://sdf.lonestar.org
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: function for difference two dates Ian Collins C Programming 20 06-22-2010 08:09 AM
How to find difference in years between two dates? thebjorn Python 23 07-29-2006 07:57 AM
Dates dates dates dates... SQL and ASP.NET David Lozzi ASP .Net 1 09-30-2005 02:18 PM
Dates! Dates! Dates! PW ASP General 4 08-09-2004 04:42 PM
Get the difference between two dates in terms of days gops C Programming 1 02-10-2004 03:59 AM



Advertisments