Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   Re: function for difference two dates (http://www.velocityreviews.com/forums/t725725-re-function-for-difference-two-dates.html)

 Ian Collins 06-16-2010 09:25 AM

Re: function for difference two dates

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

 Keith Thompson 06-16-2010 03:41 PM

Re: function for difference two dates

Ian Collins <ian-news@hotmail.com> 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?

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) kst-u@mib.org <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"

 Ike Naar 06-17-2010 07:35 AM

Re: function for difference two dates

In article <lnwrtzx9w8.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>Ian Collins <ian-news@hotmail.com> writes:
>> On 06/16/10 09:28 PM, io_x wrote:
>>> #define R return

>>
>> Why?

>
>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?
--
ike@sdf.lonestar.org
SDF Public Access UNIX System - http://sdf.lonestar.org

 Öö Tiib 06-17-2010 03:30 PM

Re: function for difference two dates

On Jun 17, 12:22*pm, "io_x" <a...@b.c.invalid> wrote:
> "Ian Collins" <ian-n...@hotmail.com> ha scritto nel messaggionews:87rjjtFj2pU1@mid.individual.net...
>
> > 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
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.

 Keith Thompson 06-17-2010 07:44 PM

Re: function for difference two dates

ike@sdf.lNoOnSePsAtMar.org (Ike Naar) writes:
> In article <lnwrtzx9w8.fsf@nuthaus.mib.org>,
> Keith Thompson <kst-u@mib.org> wrote:
>>Ian Collins <ian-news@hotmail.com> writes:
>>> On 06/16/10 09:28 PM, io_x wrote:
>>>> #define R return
>>>
>>> Why?

>>
>>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) kst-u@mib.org <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"

 Keith Thompson 06-17-2010 07:51 PM

Re: function for difference two dates

"io_x" <a@b.c.invalid> writes:
> "Ian Collins" <ian-news@hotmail.com> ha scritto nel messaggio
> news:87rjjtFj2pU1@mid.individual.net...
>> 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

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

--
Keith Thompson (The_Other_Keith) kst-u@mib.org <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"

 Seebs 06-17-2010 07:56 PM

Re: function for difference two dates

On 2010-06-17, Keith Thompson <kst-u@mib.org> 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 / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!

 Dann Corbit 06-17-2010 08:40 PM

Re: function for difference two dates

In article <lnd3vpwi7p.fsf@nuthaus.mib.org>, kst-u@mib.org says...
>
> "io_x" <a@b.c.invalid> writes:
> > "Ian Collins" <ian-news@hotmail.com> ha scritto nel messaggio
> > news:87rjjtFj2pU1@mid.individual.net...
> >> 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).

 bart.c 06-17-2010 08:47 PM

Re: function for difference two dates

"Ike Naar" <ike@sdf.lNoOnSePsAtMar.org> wrote in message
news:hvcj8h\$l7\$1@droog.sdf-eu.org...
> In article <lnwrtzx9w8.fsf@nuthaus.mib.org>,
> Keith Thompson <kst-u@mib.org> wrote:
>>Ian Collins <ian-news@hotmail.com> writes:
>>> On 06/16/10 09:28 PM, io_x wrote:
>>>> #define R return
>>>
>>> Why?

>>
>>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 T this
#define B2 before
#define A2 and
#define I if
#define T2 time
#define I2 i
#define D don
#define T3 t
#define E expect
#define H2 his
#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

 Ike Naar 06-17-2010 09:30 PM

Re: function for difference two dates

In article <lniq5hwijx.fsf@nuthaus.mib.org>,
Keith Thompson <kst-u@mib.org> wrote:
>It's just the previous paragraph with each word abbreviated to its
>initial letter.