Deutsch   English   Français   Italiano  
<vva3vc$96h2$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: That depends... (Was: Regarding assignment to struct)
Date: Mon, 5 May 2025 12:30:02 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <vva3vc$96h2$1@dont-email.me>
References: <vv338b$16oam$1@dont-email.me>
 <51ba1k5h5lkj75qvfuj0ferlddpb6bi0n8@4ax.com>
 <vv3art$2ku6u$1@news.xmission.com> <vv3qkc$2b7nd$1@dont-email.me>
 <20250502211854.795@kylheku.com> <20250502220618.480@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 05 May 2025 12:30:05 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="539f33e7a63020ae1bdbd3fb34730567";
	logging-data="301602"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+2SNBac/SDIeLRpo5sEOf5"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.8.0
Cancel-Lock: sha1:KAvJk9lIplVLInLpOBJySxsY/us=
In-Reply-To: <20250502220618.480@kylheku.com>
X-Enigmail-Draft-Status: N1110
Bytes: 2162

On 03.05.2025 07:11, Kaz Kylheku wrote:
> 
> Expanding on this point, C++ goes to town with pass-by-value interfaces
> involving objects. For instance the std::basic_string template allows
> C++ programs to treat dynamic strings as just values to be tossed
> around:
> 
>    std::string path_combine(std::string dir, std::string name)
>    {
>       return dir + "/" + name;
>    }

Hmm.. - my C++ days were long ago but I seem to recall that the
suggestion for passing non-trivial objects by-value was that they
should instead be passed by 'const &' (as a "quasi-by-value") for
performance reasons.

> C++ experience informs us that you can get away with doing this
> with PODs (plain old datatypes---structs with no constructors
> or destructors) only to a point. But in C, that's all you have.
> 
> [...]

Janis