Deutsch   English   Français   Italiano  
<pan$6153b$99b5be7e$e8a115ad$97b1fafc@invalid.invalid>

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

Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: Blue-Maned_Hawk <bluemanedhawk@invalid.invalid>
Newsgroups: comp.lang.c
Subject: Re: is it possible to have functions with 0, 1, or 2 args?
Date: Mon, 5 Aug 2024 18:46:40 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <pan$6153b$99b5be7e$e8a115ad$97b1fafc@invalid.invalid>
References: <7q-dnbTDU4oBES37nZ2dnZfqnPednZ2d@brightview.co.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 05 Aug 2024 20:46:41 +0200 (CEST)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="5b852bb8e886d7cc5d0ae55022d1492d";
	logging-data="930334"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/9raQAI7vYrV00IwYfCCfBGshV/6llof4="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:yPomLSmm3rQHGIXHaRsOY/QS3s8=
X-Face: Taumatawhakatangihangakoauauotamateaturipukakapikimaungahoronuku
 pokaiwhenuakitanatahu
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
 MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
 ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
 rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
 jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
 0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
 z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
 fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
 R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
 O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
 j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
 k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
 2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
 GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
 xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
Bytes: 4011

Mark Summerfield wrote:

> The rational is that I'd like to create a function `new_thing()` which
> takes an optional size, e.g.,
> 
> ```
> thing new_thing0() { return new_thing1(10); }
> // above uses default size of 10 thing new_thing1(int size) { ... }
> ```

If i were you, i would have put the desired end result first in the 
message and attempted solution afterwards, as i consider this to put the 
most relevant information first.  I'm also pretty sure that whatever 
newsreader you're using is screwing up the line breaks in your message—i 
would recommend seeking a fix for that wherever you find support for your 
newsreader.

With that out of the way…

I question why you want a subroutine with “an optional size”.  What does 
it do when the size _isn't_ given?  If it does something completely 
different (e.g. creating only a partial object instead of a full object), 
i would just have two separate subroutines, one sized and one not.  If it 
uses a default size, then i'd be worried about it causing problems in code 
written to use it being difficult to read later on because it hides 
information from the reader.

Nevertheless, if you're undeterred, i think that you're on the right track 
with the macros that you've created.  Luckily for you, it seems as though 
this appears to be a wheel that has already been invented:  the P99 
preprocessor library seems to define some macros that can apparently be 
used for such a thing:  <https://gustedt.gitlabpages.inria.fr/p99/p99-
html/group__default__arguments.html>

As a side note, i don't know of a single newsreader that supports 
interpretation of markdown syntax in messages.  

-- 
Blue-Maned_Hawk│shortens to Hawk│/blu.mɛin.dʰak/│he/him/his/himself/Mr.
blue-maned_hawk.srht.site
Consistent except for all the inconsistencies!