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


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

Re: What a reference actually is

Newsgroups comp.lang.c++
Date 2022-11-19 15:35 -0800
References (2 earlier) <tl7ju8$1bu7$1@gioia.aioe.org> <42d9be9e-99f9-45dc-9001-b74bfedd8107n@googlegroups.com> <tla0tm$367b9$2@dont-email.me> <1fa49f55-80ce-45de-80da-708da2ebc783n@googlegroups.com> <tlbls5$3ad1l$1@dont-email.me>
Message-ID <e827cabc-5ce8-4458-a37a-e41b840ee155n@googlegroups.com> (permalink)
Subject Re: What a reference actually is
From Michael S <already5chosen@yahoo.com>

Show all headers | View raw


On Sunday, November 20, 2022 at 12:38:14 AM UTC+2, Paavo Helde wrote:
> 19.11.2022 18:20 Michael S kirjutas: 
> > I don't know about your or Juha, but I personally draw a line at DRY. 
> > Features that help to DRY can be controversial, can be even harmful, 
> > (as many preprocessor macros) but they are not nutrient-free syntactic 
> > sugar.
> [...]
> > C++ references do not help DRY at all, except if you consider & here 
> > or * there as repeating yourself. And, IMHO, presence of references 
> > in the language makes understanding somebody else's code 
> > significantly harder.
> That's strange, are you sure you mean the same DRY ("Don't repeat 
> yourself")? Because with pointers you need to consider and repeat the 
> fact that you are calling via a pointer at each call site, with 
> references this is not so. 
> 

As I said, "except if you consider & here or * there as repeating yourself."
I don't. Also, even those who considered it repeating would agree that
it is non dangerous sort of repeating, because each time you did it wrong
compiler will catch you.

> I agree the code might be hard to understand if references or pointers 
> are abused for implementing "output parameters".

You mean tuples?
May be, they should be used more, but syntax is rather ugly.
Even pairs look ugly.

>  But thankfully, C++ has 
> perfectly fine ways to return multiple values from the function, so 
> there is no need to abuse pointers or references for that purpose.
>  And 
> for normal input parameters references (const or rvalue) are just fine 
> and often a much better choice than pointers. 
> 
> Also, if you say presence of references is what makes C++ hard to 
> understand, I start to suspect you haven't seen half of C++ yet. Look up 
> any template code posts from Bonita, for starters ;-)

Of course, I recognize that references are a small nuisance relatively
to 100 other features in C++, including 75 features  that considered
god-send by "modern C++" enthusiasts.

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


Thread

What a reference actually is Juha Nieminen <nospam@thanks.invalid> - 2022-11-17 09:01 +0000
  Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-17 06:09 -0800
    Re: What a reference actually is Paavo Helde <eesnimi@osa.pri.ee> - 2022-11-18 00:36 +0200
      Re: What a reference actually is JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-11-18 07:49 +0200
      Re: What a reference actually is Tim Rentsch <tr.17687@z991.linuxsc.com> - 2022-11-20 05:48 -0800
    Re: What a reference actually is Juha Nieminen <nospam@thanks.invalid> - 2022-11-18 09:40 +0000
      Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-18 03:23 -0800
        Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-18 05:11 -0800
        Re: What a reference actually is James Kuyper <jameskuyper@alumni.caltech.edu> - 2022-11-19 02:34 -0500
          Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-19 08:20 -0800
            Re: What a reference actually is Paavo Helde <eesnimi@osa.pri.ee> - 2022-11-20 00:37 +0200
              Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-19 15:35 -0800
            Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-19 15:13 -0800
              Re: What a reference actually is "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-19 15:18 -0800
                Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-19 15:33 -0800
                Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-19 15:36 -0800
                Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-19 15:43 -0800
                Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-19 15:51 -0800
                Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-19 17:57 -0800
                Re: What a reference actually is "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-19 19:56 -0800
                Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-20 03:47 -0800
                Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-20 04:24 -0800
                Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-20 06:32 -0800
                Re: What a reference actually is "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2022-11-21 16:32 -0800
                Re: What a reference actually is Öö Tiib <ootiib@hot.ee> - 2022-11-22 08:30 -0800
              Re: What a reference actually is Michael S <already5chosen@yahoo.com> - 2022-11-19 15:27 -0800
                Re: What a reference actually is Paavo Helde <eesnimi@osa.pri.ee> - 2022-11-20 01:28 +0200
      Re: What a reference actually is Paavo Helde <eesnimi@osa.pri.ee> - 2022-11-18 14:51 +0200
        Re: What a reference actually is JiiPee <kerrttuPoistaTama11@gmail.com> - 2022-11-18 18:32 +0200
        Re: What a reference actually is Juha Nieminen <nospam@thanks.invalid> - 2022-11-21 11:56 +0000
  Re: What a reference actually is Bonita Montero <Bonita.Montero@gmail.com> - 2022-11-17 19:27 +0100
  Re: What a reference actually is Jorgen Grahn <grahn+nntp@snipabacken.se> - 2022-11-19 17:10 +0000
    Re: What a reference actually is Juha Nieminen <nospam@thanks.invalid> - 2022-11-21 11:59 +0000

csiph-web