Re: is it possible to have functions with 0, 1, or 2 args?

Liste des GroupesRevenir à l c 
Sujet : Re: is it possible to have functions with 0, 1, or 2 args?
De : bluemanedhawk (at) *nospam* invalid.invalid (Blue-Maned_Hawk)
Groupes : comp.lang.c
Date : 05. Aug 2024, 20:46:40
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <pan$6153b$99b5be7e$e8a115ad$97b1fafc@invalid.invalid>
References : 1
User-Agent : Pan/0.154 (Izium; 517acf4)
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!

Date Sujet#  Auteur
5 Aug 24 * is it possible to have functions with 0, 1, or 2 args?15Mark Summerfield
5 Aug 24 +- Re: is it possible to have functions with 0, 1, or 2 args?1Stefan Ram
5 Aug 24 +* Re: is it possible to have functions with 0, 1, or 2 args?4Stefan Ram
5 Aug 24 i+* Re: is it possible to have functions with 0, 1, or 2 args?2Stefan Ram
8 Aug 24 ii`- Re: is it possible to have functions with 0, 1, or 2 args?1Lawrence D'Oliveiro
11 Aug 24 i`- Re: is it possible to have functions with 0, 1, or 2 args?1Tim Rentsch
5 Aug 24 +* Re: is it possible to have functions with 0, 1, or 2 args?6Michael S
12 Aug 24 i`* Re: is it possible to have functions with 0, 1, or 2 args?5Tim Rentsch
12 Aug 24 i `* Re: is it possible to have functions with 0, 1, or 2 args?4Richard Harnden
12 Aug 24 i  `* Re: is it possible to have functions with 0, 1, or 2 args?3Tim Rentsch
12 Aug 24 i   `* Re: is it possible to have functions with 0, 1, or 2 args?2Richard Harnden
13 Aug 24 i    `- Re: is it possible to have functions with 0, 1, or 2 args?1Tim Rentsch
5 Aug 24 +- Re: is it possible to have functions with 0, 1, or 2 args?1Stefan Ram
5 Aug 24 +- Re: is it possible to have functions with 0, 1, or 2 args?1Blue-Maned_Hawk
12 Aug 24 `- Re: is it possible to have functions with 0, 1, or 2 args?1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal