Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #70741

Re: Two silly problems

Subject Re: Two silly problems
Newsgroups comp.lang.c++
References <qu2kmo$6f4$1@dont-email.me> <h6k3g7Fp6iaU1@mid.individual.net> <5SKNF.20703$vj3.18073@fx10.dcg> <qu7vvs$129g$1@gioia.aioe.org>
From Mr Flibble <flibble@i42.removethisbit.co.uk>
Message-ID <v4MNF.45404$YR4.27837@fx18.dcg> (permalink)
Organization http://www.NewsDemon.com
Date 2019-12-28 17:15 +0000

Show all headers | View raw


On 28/12/2019 16:30, boltar@nowhere.org wrote:
> On Sat, 28 Dec 2019 15:51:29 +0000
> Mr Flibble <flibble@i42.removethisbit.co.uk> wrote:
>> On 28/12/2019 06:37, Alf P. Steinbach wrote:
>>> Here the two functions manage to create a local variable called `board`,
>>> of the exact same type in the code as by your argumentation you would
>>> have written it, and in corresponding code by me.
>>>
>>> In the assumed-like-Leigh code the `std::` qualification and the type
>>> builder `array` is repeated ad nauseam, because you argue that even when
>>> it's known that all textual instances are a given text it should better
>>> be spelled out; and the focus, what's communicated to a reader, is on
>>> the details of the data representation and not on what it models.
>>>
>>> In the more DRY (Don't Repeat Yourself) Alf code the relevant namespace
>>> `std::` is mentioned only once; the type builder `array` is mentioned
>>> only in a `using` declaration and for the two types that it builds here,
>>> that is, three times; and the focus, what's communicated to a reader, is
>>> on what the structure models.
>>
>> Alf, using deliberate exaggeration to try to invalidate a person's
>> argument is disingenuous at best but I am sure you know this.
>>
>> void real_leigh()
>> {
>>      std::size_t const width     = 8;
>>      std::size_t const height    = width;
>>
>>      using row       = std::array<int, width>;
>>      using board     = std::array<row, height>;
>>
>>      Board board{};
>>      (void) board; // Whatever
>> }
> 
> Or since board is just storing ints you could both make it even simpler still
> using C99:
> 
> 	size_t const width     = 8;
> 	size_t const height    = width;
> 
> 	typedef int Board[width][height];
> 	Board board;
> 
> Just saying.

Simpler isn't always better and one could argue that old C-style arrays 
can make certain code that *uses* them more complicated versus 
std::array usage.  More or less the only use-case for C-style arrays in 
modern C++ are dynamic arrays for allocating uninitialized buffers; 
std::array is superior to C-style arrays for nearly all other use-cases 
due to the container-like interface it offers with NO associated 
overhead in offering it. Just saying.

/Flibble

-- 
“You won’t burn in hell. But be nice anyway.” – Ricky Gervais
“I see Atheists are fighting and killing each other again, over who 
doesn’t believe in any God the most. Oh, no..wait.. that never happens.” 
– Ricky Gervais
"Suppose it's all true, and you walk up to the pearly gates, and are 
confronted by God," Bryne asked on his show The Meaning of Life. "What 
will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery 
that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates 
a world that is so full of injustice and pain. That's what I would say."

Back to comp.lang.c++ | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Two silly problems "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-26 16:47 +0100
  Re: Two silly problems "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-26 16:51 +0100
  Re: Two silly problems Bo Persson <bo@bo-persson.se> - 2019-12-26 16:55 +0100
    Re: Two silly problems "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-27 05:07 +0100
      Re: Two silly problems Mr Flibble <flibble@i42.removethisbit.co.uk> - 2019-12-27 16:38 +0000
        Re: Two silly problems "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-27 20:05 +0100
          Re: Two silly problems Mr Flibble <flibble@i42.removethisbit.co.uk> - 2019-12-28 00:42 +0000
            Re: Two silly problems "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2019-12-28 07:37 +0100
              Re: Two silly problems Mr Flibble <flibble@i42.removethisbit.co.uk> - 2019-12-28 15:51 +0000
                Re: Two silly problems boltar@nowhere.org - 2019-12-28 16:30 +0000
                Re: Two silly problems Mr Flibble <flibble@i42.removethisbit.co.uk> - 2019-12-28 17:15 +0000

csiph-web