Re: [DNG] simple-netaid from scratch

2019-06-11 Thread Didier Kryn

Le 11/06/2019 à 20:40, Steve Litt a écrit :

On Mon, 10 Jun 2019 15:01:53 +0100
s@po  wrote:


On Mon, 10 Jun 2019 13:34:54 +0100 (BST)
Jim Jackson  wrote:
  

sizeof()  is calculated by the compiler, not at run time. The code
generated would be the same.

Hello Jim,
Indeed it his, my point was only a observation, that if size is
fixed, no need to calculate it at compile time, the preprocessor can
solve that with a macro.. The code generated will be indeed the same.
Only was  a observation ;)

I vote for leaving it as a function.

What would be gained by making it a macro? A microsecond? What are the
bottlenecks of the software? Are keyboard or mouse input involved?

If these sizeof() calls are deep in a tight nested loop, by all means
make them into a macro. Otherwise, why give up the simplicity of a
function for the sometimes edge case weirdness of a macro?

It's funny. So many times people advocate jumping through hoops to save
a millisecond in a program operated by and therefore bottlenecked by a
100wpm typist. 100wpm is 500 keystrokes per minute, or 8.33 keystrokes
per second, which means each keystroke takes 120 milliseconds. The 1ms
savings *just doesn't matter*.

And yes,  as a matter of fact, I often do use "useless use of cat".
Costs me nothing perceptible, and makes it easier to rearrange
pipelines til I get them right.

    I fully agree that gaining milisecond is often futile. But this has 
nothing to do with this discussion. The discussion was only about style.


    sizeof() is not a real function. Its syntax makes it look like a 
function but it is not. Its argument can be either a variable or a type 
(which no function can have). It is evaluated at compile time - which is 
equivalent to replacing it with the litteral value.


    Didier


___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] simple-netaid from scratch

2019-06-11 Thread Steve Litt
On Tue, 11 Jun 2019 22:07:22 +0100 (BST)
Jim Jackson  wrote:

> On Tue, 11 Jun 2019, Steve Litt wrote:
> 
> > On Mon, 10 Jun 2019 15:01:53 +0100
> > s@po  wrote:
> >   
> > > On Mon, 10 Jun 2019 13:34:54 +0100 (BST)
> > > Jim Jackson  wrote:
> > >
> > > > 
> > > > sizeof()  is calculated by the compiler, not at run time. The
> > > > code generated would be the same.
> > > 
> > > Hello Jim,
> > > Indeed it his, my point was only a observation, that if size is
> > > fixed, no need to calculate it at compile time, the preprocessor
> > > can solve that with a macro.. The code generated will be indeed
> > > the same. Only was  a observation ;)  
> > 
> > I vote for leaving it as a function.
> > 
> > What would be gained by making it a macro? A microsecond? What are
> > the bottlenecks of the software? Are keyboard or mouse input
> > involved?
> > 
> > If these sizeof() calls are deep in a tight nested loop, by all
> > means make them into a macro. Otherwise, why give up the simplicity
> > of a function for the sometimes edge case weirdness of a macro?  
> 
> I do wish people would read. Those sizeof()'s are not executable
> functions, they are calculated by the compiler at compile time into
> their fixed numbers and inserted into the code as fixed numbers, just
> as a macro would! There is no difference at runtime. The code
> generated would be identical.
> 
> There is no execution penalty to using sizeof()!

Then sizeof() is perfect for the job.
 
SteveT

Steve Litt 
June 2019 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] simple-netaid from scratch

2019-06-11 Thread Jim Jackson



On Tue, 11 Jun 2019, Steve Litt wrote:

> On Mon, 10 Jun 2019 15:01:53 +0100
> s@po  wrote:
> 
> > On Mon, 10 Jun 2019 13:34:54 +0100 (BST)
> > Jim Jackson  wrote:
> >  
> > > 
> > > sizeof()  is calculated by the compiler, not at run time. The code 
> > > generated would be the same.  
> > 
> > Hello Jim,
> > Indeed it his, my point was only a observation, that if size is
> > fixed, no need to calculate it at compile time, the preprocessor can
> > solve that with a macro.. The code generated will be indeed the same.
> > Only was  a observation ;)
> 
> I vote for leaving it as a function.
> 
> What would be gained by making it a macro? A microsecond? What are the
> bottlenecks of the software? Are keyboard or mouse input involved?
> 
> If these sizeof() calls are deep in a tight nested loop, by all means
> make them into a macro. Otherwise, why give up the simplicity of a
> function for the sometimes edge case weirdness of a macro?

I do wish people would read. Those sizeof()'s are not executable functions,
they are calculated by the compiler at compile time into their fixed 
numbers and inserted into the code as fixed numbers, just as a macro would!
There is no difference at runtime. The code generated would be identical.

There is no execution penalty to using sizeof()!
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] simple-netaid from scratch

2019-06-11 Thread Antony Stone
On Tuesday 11 June 2019 at 20:40:09, Steve Litt wrote:

> It's funny. So many times people advocate jumping through hoops to save
> a millisecond in a program operated by and therefore bottlenecked by a
> 100wpm typist. 100wpm is 500 keystrokes per minute,

If I may pick a nit, I think it makes the succeeding arithmetic slightly 
simpler.

I believe 100wpm is 600 keystrokes per minute, because the "standard word" is 
5 letters, but there's also a space between the words?

> or 8.33 keystrokes per second,

600 per minute is 10 per second - much neater :)

> which means each keystroke takes 120 milliseconds.

100ms...

> The 1ms savings *just doesn't matter*.

Agreed :)

> And yes,  as a matter of fact, I often do use "useless use of cat".
> Costs me nothing perceptible, and makes it easier to rearrange
> pipelines til I get them right.

Antony.

-- 
It is also possible that putting the birds in a laboratory setting 
inadvertently renders them relatively incompetent.

 - Daniel C Dennett

   Please reply to the list;
 please *don't* CC me.
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


Re: [DNG] simple-netaid from scratch

2019-06-11 Thread Steve Litt
On Mon, 10 Jun 2019 15:01:53 +0100
s@po  wrote:

> On Mon, 10 Jun 2019 13:34:54 +0100 (BST)
> Jim Jackson  wrote:
>  
> > 
> > sizeof()  is calculated by the compiler, not at run time. The code 
> > generated would be the same.  
> 
> Hello Jim,
> Indeed it his, my point was only a observation, that if size is
> fixed, no need to calculate it at compile time, the preprocessor can
> solve that with a macro.. The code generated will be indeed the same.
> Only was  a observation ;)

I vote for leaving it as a function.

What would be gained by making it a macro? A microsecond? What are the
bottlenecks of the software? Are keyboard or mouse input involved?

If these sizeof() calls are deep in a tight nested loop, by all means
make them into a macro. Otherwise, why give up the simplicity of a
function for the sometimes edge case weirdness of a macro?

It's funny. So many times people advocate jumping through hoops to save
a millisecond in a program operated by and therefore bottlenecked by a
100wpm typist. 100wpm is 500 keystrokes per minute, or 8.33 keystrokes
per second, which means each keystroke takes 120 milliseconds. The 1ms
savings *just doesn't matter*.

And yes,  as a matter of fact, I often do use "useless use of cat".
Costs me nothing perceptible, and makes it easier to rearrange
pipelines til I get them right.

 
SteveT

Steve Litt 
June 2019 featured book: Thriving in Tough Times
http://www.troubleshooters.com/thrive
___
Dng mailing list
Dng@lists.dyne.org
https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng